##// END OF EJS Templates
lfs: update the HTTP status codes in error cases...
Matt Harbison -
r37711:31a0d47d default
parent child Browse files
Show More
@@ -26,6 +26,9 b' HTTP_OK = hgwebcommon.HTTP_OK'
26 26 HTTP_CREATED = hgwebcommon.HTTP_CREATED
27 27 HTTP_BAD_REQUEST = hgwebcommon.HTTP_BAD_REQUEST
28 28 HTTP_NOT_FOUND = hgwebcommon.HTTP_NOT_FOUND
29 HTTP_METHOD_NOT_ALLOWED = hgwebcommon.HTTP_METHOD_NOT_ALLOWED
30 HTTP_NOT_ACCEPTABLE = hgwebcommon.HTTP_NOT_ACCEPTABLE
31 HTTP_UNSUPPORTED_MEDIA_TYPE = hgwebcommon.HTTP_UNSUPPORTED_MEDIA_TYPE
29 32
30 33 def handlewsgirequest(orig, rctx, req, res, checkperm):
31 34 """Wrap wireprotoserver.handlewsgirequest() to possibly process an LFS
@@ -105,12 +108,16 b' def _processbatchrequest(repo, req, res)'
105 108 # "operation": "upload"
106 109 # }
107 110
108 if (req.method != b'POST'
109 or req.headers[b'Content-Type'] != b'application/vnd.git-lfs+json'
110 or req.headers[b'Accept'] != b'application/vnd.git-lfs+json'):
111 # TODO: figure out what the proper handling for a bad request to the
112 # Batch API is.
113 _sethttperror(res, HTTP_BAD_REQUEST, b'Invalid Batch API request')
111 if req.method != b'POST':
112 _sethttperror(res, HTTP_METHOD_NOT_ALLOWED)
113 return True
114
115 if req.headers[b'Content-Type'] != b'application/vnd.git-lfs+json':
116 _sethttperror(res, HTTP_UNSUPPORTED_MEDIA_TYPE)
117 return True
118
119 if req.headers[b'Accept'] != b'application/vnd.git-lfs+json':
120 _sethttperror(res, HTTP_NOT_ACCEPTABLE)
114 121 return True
115 122
116 123 # XXX: specify an encoding?
@@ -315,6 +322,6 b' def _processbasictransfer(repo, req, res'
315 322
316 323 return True
317 324 else:
318 _sethttperror(res, HTTP_BAD_REQUEST,
325 _sethttperror(res, HTTP_METHOD_NOT_ALLOWED,
319 326 message=b'Unsupported LFS transfer method: %s' % method)
320 327 return True
@@ -30,6 +30,8 b' HTTP_UNAUTHORIZED = 401'
30 30 HTTP_FORBIDDEN = 403
31 31 HTTP_NOT_FOUND = 404
32 32 HTTP_METHOD_NOT_ALLOWED = 405
33 HTTP_NOT_ACCEPTABLE = 406
34 HTTP_UNSUPPORTED_MEDIA_TYPE = 415
33 35 HTTP_SERVER_ERROR = 500
34 36
35 37
General Comments 0
You need to be logged in to leave comments. Login now