diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -28,6 +28,7 @@ HTTP_FORBIDDEN = 403 HTTP_NOT_FOUND = 404 HTTP_METHOD_NOT_ALLOWED = 405 +HTTP_NOT_ACCEPTABLE = 406 HTTP_SERVER_ERROR = 500 diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py --- a/mercurial/hgweb/protocol.py +++ b/mercurial/hgweb/protocol.py @@ -11,6 +11,8 @@ import struct from .common import ( + ErrorResponse, + HTTP_NOT_ACCEPTABLE, HTTP_OK, ) @@ -140,8 +142,8 @@ return HGTYPE2, engine, opts - # No mutually supported compression format. Fall back to the - # legacy protocol. + raise ErrorResponse(HTTP_NOT_ACCEPTABLE, + 'No common compression format') # Don't allow untrusted settings because disabling compression or # setting a very high compression level could lead to flooding diff --git a/tests/test-http-protocol.t b/tests/test-http-protocol.t --- a/tests/test-http-protocol.t +++ b/tests/test-http-protocol.t @@ -78,14 +78,15 @@ server: * (glob) transfer-encoding: chunked -Requesting a compression format that server doesn't support results will fall back to 0.1 +Server should fail when it can't agree with client on a compression format $ get-with-headers.py --hgproto '0.2 comp=aa' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' - - 200 Script output follows + 406 No common compression format + content-length: 31 content-type: application/mercurial-0.1 date: * (glob) server: * (glob) - transfer-encoding: chunked + [1] #if zstd zstd is used if available