]> source.dussan.org Git - jgit.git/commit
HTTP Smart: set correct HTTP status on error 77/192677/13
authorSven Selberg <sven.selberg@axis.com>
Tue, 12 Apr 2022 09:36:58 +0000 (11:36 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 9 May 2022 20:06:38 +0000 (22:06 +0200)
commit8984e1f663b5b58f74cd0381043133f0059e004d
tree1b2826e352f46e10a6e0676316f564ef4a2b1471
parent8f7ef245f0c156730ef74ff3fe838c330728fc7f
HTTP Smart: set correct HTTP status on error

Previous behavior was that status code was automatically set to 200
regardless of reported status and according to HTTP Smart protocol[1]:

  If there is no repository at $GIT_URL, or the resource pointed to by
  a location matching $GIT_URL does not exist, the server MUST NOT
  respond with 200 OK response. A server SHOULD respond with
  404 Not Found, 410 Gone, or any other suitable HTTP status code which
  does not imply the resource exists as requested.

Since the jgit HTTP client isn't able to handle reading content from a
response reporting an error (calling HttpURLConnection#getInputStream
on a "failed" connection throws an exception and the internal interface
HttpConnection does not expose HttpURLConnection#getErrorStream) the
SmartClientSmartServerTest needed to be rewritten to expect the generic
response messages.

[1] https://git-scm.com/docs/http-protocol#_general_request_processing

Bug: 579676
Change-Id: Ibb942d02124a0bc279df09600b091354019ce064
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java