Commit Graph

16 Commits

Author SHA1 Message Date
Gregory Szorc
3a983954a1 get-with-headers: support parsing and pretty printing JSON
Upcoming patches will add support for JSON output from hgweb.

Because JSON output from the templater is hard to read and because it
is easy to introduce malformed JSON, we introduce a JSON processing
mode to get-with-headers.py that will parse and pretty print JSON
from HTTP responses. This will make tests easier to read and write
and it will ensure hgweb is emitting well-formed JSON.
2015-03-30 20:56:54 -07:00
Gregory Szorc
9ccf5570f8 hgweb: send proper HTTP response after uncaught exception
This patch fixes a bug where hgweb would send an incomplete HTTP
response.

If an uncaught exception is raised when hgweb is processing a request,
hgweb attempts to send a generic error response and log that exception.

The server defaults to chunked transfer coding. If an uncaught exception
occurred, it was sending the error response string / chunk properly.
However, RFC 7230 Section 4.1 mandates a 0 size last chunk be sent to
indicate end of the entity body. hgweb was failing to send this last
chunk. As a result, properly written HTTP clients would assume more data
was coming and they would likely time out waiting for another chunk to
arrive.

Mercurial's own test harness was paving over the improper HTTP behavior
by not attempting to read the response body if the status code was 500.
This incorrect workaround was added in faced8f5c2af and has been removed
with this patch.
2014-11-28 10:59:02 -08:00
Javi Merino
e80cfee2b0 get-with-headers: don't block indefinitely if the server had an internal error
If the server had an internal error and returned 500, there's nothing
to read, so "response.read()" blocks indefinitely.  Only output the
response if there's really a response.
2013-10-02 22:46:32 +01:00
Pierre-Yves David
b7643c351c get-with-headers: add a --headeronly switch
In some case we do not care about the actual rendering.
2013-01-16 14:26:19 +01:00
Mads Kiilerich
ab59efec7d tests: make test-hgweb.t output stable
Instability introduced in combination of 08b18bf1e0f3 and 072a5d64ecaa.
2013-01-16 02:01:11 +01:00
Mads Kiilerich
5cabd60d62 serve: don't send any content headers with 304 responses
Fixes HTTP protocol violation introduced in e4a5f5db7028. 'hg serve' would show
a stacktrace when loading pages that not had been modified.

There was test coverage for this, but the wrong response headers wasn't shown
and thus not detected.
2013-01-15 20:54:57 +01:00
Mads Kiilerich
1fda0b1af1 tests: prepare get-with-headers.py for MSYS
get-with-headers.py took the http GET parameter as a command line parameter
that had to start with '/'. MSYS on windows will mangle such paths.

Instead of applying a workaround everywhere (such as an extra '/') we let
get-with-headers.py add the mandatory '/'. That is consistent with the
url path handling in the Mercurial url class.

A few tests sent 'GET ?cmd=...' which is invalid. They will now send 'GET
/?cmd=...'.

This will not enable any tests for being run on windows - only remove one
reason they were disabled.
2012-06-21 03:05:02 +02:00
Dirkjan Ochtman
5ec1a29d90 tests: fix incompatibility with python-2.4 in test-hgweb
Thanks to lcantey for catching it.
2010-09-11 10:57:35 +02:00
Dirkjan Ochtman
ea62f97a35 tests: extend get-with-headers to support cache testing 2010-09-08 15:11:35 +02:00
Nicolas Dumazet
7f1a963829 pylint, pyflakes: remove unused or duplicate imports 2010-04-14 17:58:10 +09:00
Dirkjan Ochtman
c08c589861 templater: readable dates older than 24 months revert to ISO8601 (issue1006) 2009-11-05 15:19:54 +01:00
Martin Geisler
9aedf5dabd tests: fix doc string in get-with-headers.py 2009-05-17 01:24:45 +02:00
Gilles Moris
9b7deb4420 test-hgweb-*: replace "XX years ago" by a fixed string in get-with-headers.py
Note that other sed replacement commands are also filtering get-with-headers.py,
but they seem to be more test specific, hence not handled here.
2008-12-25 17:49:08 +01:00
Patrick Mezard
4813e1621f get-with-headers: fix stream modes under Windows 2008-09-28 20:40:38 +02:00
Bryan O'Sullivan
e19dabc11f hgweb: return meaningful HTTP status codes instead of nonsense 2007-11-28 08:38:42 -08:00
Eric Hopper
6ae7c3c284 Add a test for getting raw files via the web UI. 2006-06-29 16:44:23 -07:00