Mercurial > public > mercurial-scm > hg-stable
diff mercurial/httppeer.py @ 32022:e5d7f99a3063
httppeer: don't send empty Vary request header
As part of writing test-http-bad-server.t, I noticed that some
requests include an empty Vary HTTP request header.
The Vary HTTP request header indicates which headers should be taken
into account when determining if a cached response can be used. It also
accepts the special value of "*".
The previous code unconditionally added a Vary header. This could lead
to an empty header value. While I don't believe this violates the HTTP
spec, this is weird and just wastes bytes. So this patch changes
behavior to only send a Vary header when it has a value.
Some low-level wire protocol byte reporting tests changed. In some
cases, the exact point of data termination changed. However, the
behavior being tested - that clients react when the connection is
closed in the middle of an HTTP request line or header - remains
unchanged.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 16 Apr 2017 11:28:02 -0700 |
parents | 84569d2b3fb7 |
children | a29580905771 |
line wrap: on
line diff
--- a/mercurial/httppeer.py Sun Apr 16 21:25:16 2017 -0400 +++ b/mercurial/httppeer.py Sun Apr 16 11:28:02 2017 -0700 @@ -218,7 +218,9 @@ headers[header] = value varyheaders.append(header) - headers['Vary'] = ','.join(varyheaders) + if varyheaders: + headers['Vary'] = ','.join(varyheaders) + req = self.requestbuilder(cu, data, headers) if data is not None: