httpbin
httpbin copied to clipboard
tests broken: content-length no longer present with werkzeug >= 0.15.1
Recent travis-ci tests fail. In particular test_get
and test_anything
.
Both tests expect the Content-Length
header to be present:
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/test_httpbin.py#L151 https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/test_httpbin.py#L165
It seems there is a behaviour change in werkzeug between version 0.14.1 and 0.15.1 (and newer), where Content-Length is only set when non zero.
Pipfile requires werkzeug >= 0.14.1: https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/Pipfile#L12
I first noticed this for my pull requests, where #543 passed the existing tests just fine. This test ran with werkzeug 0.14.1: https://travis-ci.org/postmanlabs/httpbin/jobs/504080576#L205
Where the following test failed and used werkzeug 0.15.1: https://travis-ci.org/postmanlabs/httpbin/jobs/510702985#L205
Either locking werkzeug to 0.14.1 or updating the tests and requiring werkzeug >= 0.15.1 would probably work fine also the later is preferable.
I was working on a fix for this after noticing my builds for the minor issue here https://github.com/postmanlabs/httpbin/pull/591 but noticed this fix before raising a PR. My fix was going to just be the removal of the two assertions. Good one for going the extra mile and updating the version of werkzerg too. You've got a +1 from me on your PR. Is there a maintainer around to accept this fix?
Just in case anyone was wondering as I was whether werkzeug is breaking any rules by omitting the Content-Length. No, it's all fine.
"Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4." (SHOULD as in don't have to.) Please see section 14.13 of https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html