GithubHelp home page GithubHelp logo

Content-Type header parsing about http-core HOT 16 CLOSED

annevk avatar annevk commented on August 25, 2024
Content-Type header parsing

from http-core.

Comments (16)

reschke avatar reschke commented on August 25, 2024

This appears like a browser issue to me. There is and never was an intention to have different rules.

from http-core.

annevk avatar annevk commented on August 25, 2024

I'm not sure what that means. If it affects browsers, why would it not affect other clients in the HTTP ecosystem? Don't we all consume the same content?

from http-core.

reschke avatar reschke commented on August 25, 2024

Once again, there are no different rules. Browsers apparently implemented workarounds for misconfigured servers, but that doesn't mean that what browsers do is what everybody else is doing.

from http-core.

mnot avatar mnot commented on August 25, 2024

Do we need to do more than reference mimesniff (see #51)? Note there's already generic text about sniffing in Content-Type.

from http-core.

annevk avatar annevk commented on August 25, 2024

This issue is really about parsing Content-Type and determining its (parsed) value, irrespective of any sniffing that might also take place.

from http-core.

annevk avatar annevk commented on August 25, 2024

More concretely, text/html, text/plain means text/plain in browsers. text/plain; means text/plain (not an error). text/html;charset=gbk, text/html means text/html;charset=gbk (yup, charset is copied over as a special case).

whatwg/fetch#831 has a patch for Fetch to define this in detail with an acknowledgment that it doesn't match HTTP.

It seems greatly preferable to uplift this kind of thing and agree on header parsers across the HTTP ecosystem, but if that's not doable so be it.

from http-core.

mnot avatar mnot commented on August 25, 2024

Discussed in Basel; we could document a suggested error handling algorithm, as long as it's clear that rejecting the message because the content-type is invalid is still acceptable.

Suggested algorithm would be to use the last syntactically valid type. @annevk does that align with fetch?

from http-core.

annevk avatar annevk commented on August 25, 2024

More than today, but it's also more involved: https://fetch.spec.whatwg.org/#content-type-header.

from http-core.

mnot avatar mnot commented on August 25, 2024

Waiting for terminology from #193.

from http-core.

reschke avatar reschke commented on August 25, 2024

I just updated my ancient tests for content-type, see http://test.greenbytes.de/tech/tc/httpcontenttype.

To my surprise, Safari apparently handles comma-separated different from multiple fields, see http://test.greenbytes.de/tech/tc/httpcontenttype/#multitextxmloneline.

@annevk, that would be a bug according to FETCH, right?

from http-core.

annevk avatar annevk commented on August 25, 2024

Yes, I suspect there's a bug filed already. I think I found such bugs in all browsers as they all have very similar logic in their core HTTP parsers.

from http-core.

reschke avatar reschke commented on August 25, 2024

Ah. But then, I'm not really convinced that we should add this to the spec. My understanding that the request was based on browsers already agreeing on the error handling...

from http-core.

annevk avatar annevk commented on August 25, 2024

There's no complete agreement on all details involved. See whatwg/fetch#831 (comment) for links to bugs.

from http-core.

reschke avatar reschke commented on August 25, 2024

I did some more testing with Java client libs (HTTPURLConnection, JDK HttpClient, Apache HttpClient). Of these, only the first seems to have an API getting the type directly, and that indeed takes the last value (no matter whether sent as list in a single instance, or in multiple fields).

It would be nice if there was a concrete Webkit bug that points out their inconsistency (see #39 (comment)) (cc @tfpauly).

from http-core.

annevk avatar annevk commented on August 25, 2024

I recommend either filing one that blocks https://bugs.webkit.org/show_bug.cgi?id=192000 or detailing the specific case you care about there in a comment.

from http-core.

reschke avatar reschke commented on August 25, 2024

done: https://bugs.webkit.org/show_bug.cgi?id=215604

from http-core.

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.