Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix http output to never have both transfer-encoding and content-length #1776

Closed
wants to merge 1 commit into from

Conversation

wemeetagain
Copy link
Member

Fixes #1765

Since our http responses are unconditionally sending a non-identity Transfer-Encoding header, we shouldn't send a Content-Length Header.

This patch changes the output Content-Length to X-Content-Length to resolve that issue and adds a test to confirm that Transfer-Encoding and Content-Length are not both specified.

@jbenet jbenet added the backlog label Oct 2, 2015
'

test_expect_success "Only one of Transfer-Encoding or Content-Length exists" '
! [ `cat has_te` -ne 0 -a `cat has_cl` -ne 0 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably use

! [ `test -f has_te` -a `test -f has_cl` ]

@wemeetagain
Copy link
Member Author

It was breaking a non-conforming http client I was using, not breaking anything anymore. I'd be happy to leave as is, since any conformant http client should be ignoring content-length when a non-identity transfer-encoding is also present.

@jbenet
Copy link
Member

jbenet commented Oct 2, 2015

@diasdavid saw something weird today. on https://ipfs.io homepage:

https://ipfs.io/styles/bootstrap/css/bootstrap.min.css Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
https://ipfs.io/styles/img/main/alpha-sunrise-2000x1682.png Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
html5player-new.js:309 SVG's SMIL animations (<animate>, <set>, etc.) are deprecated and will be removed. Please use CSS animations or Web animations instead.
https://static.doubleclick.net/instream/ad_status.js Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
2chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
3chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
3chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
3chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
3chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
3chrome-extension://eojlgccfgnjlphjnlopmadngcgmmdgpk/cast_sender.js Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
Chrome - Version 45.0.2454.101 

but then it stopped. may be worth merging to avoid this.

though i wonder what this was..... how would the length vary?

@whyrusleeping
Copy link
Member

We had decided in another PR that we should set the header X-Content-Length or similar, so clients who want the info have it, but so that we also dont break things that make poor assumptions.

@jbenet
Copy link
Member

jbenet commented Oct 9, 2015

We should also always return correct length-- have seen it off sometimes

On Thursday, October 8, 2015, Jeromy Johnson notifications@github.com
wrote:

We had decided in another PR that we should set the header
X-Content-Length or similar, so clients who want the info have it, but so
that we also dont break things that make poor assumptions.


Reply to this email directly or view it on GitHub
#1776 (comment).

@whyrusleeping
Copy link
Member

@wemeetagain @jbenet update here?

@wemeetagain
Copy link
Member Author

Not sure about the incorrect content length being sent, but I'll shortly update the PR to return the X-Content-Length header instead of simply suppressing the content length.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
RFC2616 states that one must not have both transfer-encoding and
content-length.

This patch changes the Content-Length header to
X-Content-Length to avoid the conflict.

License: MIT
Signed-off-by: Cayman Nava <caymannava@gmail.com>
@wemeetagain
Copy link
Member Author

updated~, OP edited to reflect changes.

@jbenet
Copy link
Member

jbenet commented Oct 27, 2015

maybe this is a good way to avoid breaking things if the thing is incorrect header.

before merging, feedback @mappum @diasdavid ?

@daviddias
Copy link
Member

It has been a long time since I saw that error. Setting up Content-Length LGTM as it is the standardised header for that purpose

@jbenet
Copy link
Member

jbenet commented Nov 2, 2015

@diasdavid this is not using Content-Length but rather making sure we don't use it. @mappum thoughts?

@RichardLitt
Copy link
Member

I think switching to X-Content-Length is a smart move. But I'm not sure we need to provide content-length at all for this; cat shouldn't be returning it .

@ghost
Copy link

ghost commented Dec 22, 2015

LGTM

@ghost ghost added the RFM label Dec 22, 2015
@daviddias daviddias removed the backlog label Jan 2, 2016
@whyrusleeping
Copy link
Member

I believe this has been resolved in a different PR, i no longer see both content length and chunked encoding together. If it is still an issue please reopen this PR, or file an issue with repro steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP API - cat output has both Content-Length and Transfer-Encoding
5 participants