Giter Club home page Giter Club logo

Comments (1)

spekulatius avatar spekulatius commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.