]> source.dussan.org Git - jgit.git/commit
Add utilities for smart HTTP error handling 67/4667/1
authorShawn O. Pearce <spearce@spearce.org>
Tue, 22 Nov 2011 23:51:11 +0000 (15:51 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 22 Nov 2011 23:51:14 +0000 (15:51 -0800)
commit867087bb1119aa0ed52c01095c121229929c007e
treee492a1bd7ca54fa6da4a561655970cffda41676a
parent9d311b333347d13ff2f9e0b7109e6b164a3643cc
Add utilities for smart HTTP error handling

The GitSmartHttpTools class started as utility functions to help report
useful error messages to users of the android.googlesource.com service.

Now that the GitServlet and GitFilter classes support filters before a
git-upload-pack or git-receive-pack request, server implementors may
these routines helpful to report custom messages to clients.  Using the
sendError() method to return an HTTP 200 OK with error text embedded in
the payload prevents native Git clients from retrying the action with a
dumb Git or WebDAV HTTP request.

Refactor some of the existing code to use these new error functions and
protocol constants.  The new sendError() function is very close to being
identical to the old error handling code in RepositoryFilter, however we
now use the POST Content-Type rather than the Accept HTTP header to check
if the client will accept the error data in the response body rather than
using the HTTP status code.  This is a more reliable way of checking for
native Git clients, as the Accept header was not always populated with the
correct string in older versions of Git smart HTTP.

Change-Id: I828ac2deb085af12b6689c10f86662ddd39bd1a2
org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java [new file with mode: 0644]
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java