Multiple "Content-Length" in HTTP headers

445 views
Skip to first unread message

kn...@google.com

unread,
Feb 18, 2016, 7:22:56 PM2/18/16
to net-dev
Hello net-dev,

I was wondering what would Android Chromium behavior be if there are multiple "Content-Length" entries returned in the response headers. Which one will be chosen eventually, and would this break rendering in any way?

The context is that I was toying with the Android's shouldInterceptRequest API. It turns out that shouldInterceptRequest always inject a "Content-Length: 0" in the response, so providing an additional Content-Length header via the API with a valid positive length would make this header field a repeated one. For instance for one response using this API the headers show up as "Content-Length: 0, 428" in the Chrome inspector.

Thank you in advance!

Matt Menke

unread,
Feb 18, 2016, 7:28:07 PM2/18/16
to kn...@google.com, net-dev
We consider receiving two different content-length values a fatal error, so we fail the request without reading the body when that happens.


--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/c3f57c9b-8943-4605-8569-efea69387241%40chromium.org.

Eric Roman

unread,
Feb 18, 2016, 7:34:22 PM2/18/16
to Matt Menke, kn...@google.com, net-dev

kn...@google.com

unread,
Feb 18, 2016, 8:05:51 PM2/18/16
to net-dev, mme...@chromium.org, kn...@google.com
Thanks for the info! It's quite strange that I was able to see the request/respond coming through on Android's chromium webview successfully though..

Also, what would happen if "Content-Length" is set to 0 (just one value), would chrome continue to download the body in that case.

Matt Menke

unread,
Feb 18, 2016, 9:02:45 PM2/18/16
to kn...@google.com, net-dev
Oh...you're using some funky API for hooking the network stack, not using an HTTP server.  Headers that don't actually come from HTTP are largely ignored, since they only have a real meaning when they're received over HTTP.  There are a few exceptions:  Cookies, redirects, not sure what else.
Reply all
Reply to author
Forward
0 new messages