hgweb: respond 403 forbidden for ssl required error
It's preferable to report "ssl required" as an error, so that the client
can detect error and exit with 255. Currently hg exits with 1, which is
"nothing to push."
--- a/mercurial/hgweb/common.py Wed Sep 05 23:58:43 2012 +0900
+++ b/mercurial/hgweb/common.py Wed Sep 05 23:59:27 2012 +0900
@@ -48,7 +48,7 @@
# and replayed
scheme = req.env.get('wsgi.url_scheme')
if hgweb.configbool('web', 'push_ssl', True) and scheme != 'https':
- raise ErrorResponse(HTTP_OK, 'ssl required')
+ raise ErrorResponse(HTTP_FORBIDDEN, 'ssl required')
deny = hgweb.configlist('web', 'deny_push')
if deny and (not user or deny == ['*'] or user in deny):
--- a/tests/test-push-http.t Wed Sep 05 23:58:43 2012 +0900
+++ b/tests/test-push-http.t Wed Sep 05 23:59:27 2012 +0900
@@ -29,11 +29,9 @@
$ req
pushing to http://localhost:$HGPORT/
searching for changes
- remote: ssl required
- remote: ssl required
- updating cb9a9f314b8b to public failed!
+ abort: HTTP Error 403: ssl required
% serve errors
- [1]
+ [255]
expect authorization error