Comments (1)
Hey @eposjk,
To separate the topic a bit better I'd suggest to continue the conversion on headers here.
Yes, they could be helpful.
But how should be expose them? When we look at https://github.com/symfony/browser-kit/blob/6.2/Response.php, we see that
$web->client->getResponse()->getHeader('Some-Header')
normalizes the header name (case and -_) - and$web->client->getResponse()->getHeaders()
return all unnormalized headers. And$web->client->getResponse()->getHeader('Some-Header', false)
returns an array of maybe multiple headers of the same kind.
Yeah, that a good point on the converting. It appears as if the processing in $web->client->getResponse()->getHeader('Some-Header')
is quite useful: normalizing and returning a result depending on the type.
To match with the current naming, I would make getHeaders()
-> headersRaw()
(for those wanting to access every detail). The definition and usage of getHeader()
makes sense too. Why not expose it directly as it is?
I think it also makes sense to have some basic test to ensure the behavior of the underlying library doesn't change. The three cases as above on some example page should do.
What are the use cases:
* check one header (e.g. Date, Last-Modified, Expires, Content-Language) * store all headers to use them later (normalized with `$normalizedHeader = ucwords(strtolower($header), '-_')` ?)
Do we need to support multiple headers of the same type? It seems that there are two notations to set multiple values for a header: sending multiple headers with the same name and folding them separated by ", ". Folding seems to be allowed for all except a deprecated form of the Set-Cookie header which uses the Expires=... parameter (instead of the newer Max-Age parameter). What about folding all parameter in our getHeaders() function and transforming Set-Cookie+Expires to Set-Cookie+Max-Age and normalizing them as described above?
Multiple headers of the same type could come up. Normalizing data is fine, as we expose the raw data in case people want to tweak stuff. I haven't found anything about the deprecated header on the page. The conversion from Set-Cookie+Expires to Set-Cookie+Max-Age should be fine, as long as it's documented proper.
from phpscraper.
Related Issues (20)
- [Proposal] Exposing Goutte/Client via client() property/callable method HOT 1
- Allow to set cookies
- TypeError HOT 3
- get http status code HOT 7
- Parsing structured data (microdata) HOT 3
- Idea: Discovery Sets
- Idea: Implement low-level util to access the web. HOT 1
- What location PHPSCrapper based on? HOT 1
- Docker Composer Install Error HOT 12
- [Request] Add robots.txt parsing HOT 3
- [Request] Sitemap Index Files HOT 2
- Syntax Error when i tried using PHP 7.3 HOT 3
- fabpot/goutte HOT 14
- Spanish web content not displayed correctly '?' is putted instead of the correct character HOT 1
- Fix problems reported by PHPStan HOT 5
- psr/http-message 2.0 compatibility HOT 2
- issue about php scraping api HOT 1
- Scraping a site with CloudFlare protection/redirect returns no results HOT 2
- upgrade path for 3.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpscraper.