Top Description Fields Constructors Methods
org.eclipse.jgit.lfs.server.fs

public Class FileLfsServlet

extends HttpServlet
Class Inheritance
Annotations
@WebServlet
asyncSupported:true
Imports
java.io.IOException, .PrintWriter, java.text.MessageFormat, jakarta.servlet.AsyncContext, .ServletException, jakarta.servlet.annotation.WebServlet, jakarta.servlet.http.HttpServlet, .HttpServletRequest, .HttpServletResponse, org.apache.http.HttpStatus, org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException, org.eclipse.jgit.lfs.lib.AnyLongObjectId, .Constants, .LongObjectId, org.eclipse.jgit.lfs.server.internal.LfsGson, .LfsServerText

Servlet supporting upload and download of large objects as defined by the GitHub Large File Storage extension API extending git to allow separate storage of large files (https://github.com/github/git-lfs/tree/master/docs/api).
Since
4.3

Field Summary

Modifier and TypeField and Description
private final FileLfsRepository
private static final long
private final long
Inherited from jakarta.servlet.http.HttpServlet:
LEGACY_DO_HEAD

Constructor Summary

AccessConstructor and Description
public
FileLfsServlet(FileLfsRepository
the repository storing the large objects
repository
,
long
timeout for object upload / download in milliseconds
timeout
)

Constructor for FileLfsServlet.

Method Summary

Modifier and TypeMethod and Description
protected void
doGet(HttpServletRequest
an HttpServletRequest object that contains the request the client has made of the servlet
req
,
HttpServletResponse
an HttpServletResponse object that contains the response the servlet sends to the client
rsp
)

Overrides jakarta.servlet.http.HttpServlet.doGet.

Called by the server (via the service method) to allow a servlet to handle a GET request.

protected void
doPut(HttpServletRequest
the HttpServletRequest object that contains the request the client made of the servlet
req
,
HttpServletResponse
the HttpServletResponse object that contains the response the servlet returns to the client
rsp
)

Overrides jakarta.servlet.http.HttpServlet.doPut.

Called by the server (via the service method) to allow a servlet to handle a PUT request.

protected AnyLongObjectId

Returns:

object id, or null if the object id could not be retrieved
getObjectToTransfer
(HttpServletRequest
servlet request
req
,
HttpServletResponse
servlet response
rsp
)

Retrieve object id from request

protected static void
sendError(HttpServletResponse
the servlet response
rsp
,
int
HTTP status code
status
,
String
error message
message
)

Send an error response.

Inherited from jakarta.servlet.http.HttpServlet:
doDeletedoHeaddoOptionsdoPatchdoPostdoTracegetLastModifiedinitisSensitiveHeaderserviceservice

Field Detail

repositoryback to summary
private final FileLfsRepository repository
serialVersionUIDback to summary
private static final long serialVersionUID

Hides jakarta.servlet.http.HttpServlet.serialVersionUID.

timeoutback to summary
private final long timeout

Constructor Detail

FileLfsServletback to summary
public FileLfsServlet(FileLfsRepository repository, long timeout)

Constructor for FileLfsServlet.

Parameters
repository:FileLfsRepository

the repository storing the large objects

timeout:long

timeout for object upload / download in milliseconds

Method Detail

doGetback to summary
protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException

Overrides jakarta.servlet.http.HttpServlet.doGet.

Doc from jakarta.servlet.http.HttpServlet.doGet.

Called by the server (via the service method) to allow a servlet to handle a GET request.

Overriding this method to support a GET request also automatically supports an HTTP HEAD request. A HEAD request is a GET request that returns no body in the response, only the request header fields.

When overriding this method, read the request data, write the response headers, get the response's writer or output stream object, and finally, write the response data. It's best to include content type and encoding. When using a PrintWriter object to return the response, set the content type before accessing the PrintWriter object.

The servlet container must write the headers before committing the response, because in HTTP the headers must be sent before the response body.

Where possible, set the Content-Length header (with the jakarta.servlet.ServletResponse#setContentLength method), to allow the servlet container to use a persistent connection to return its response to the client, improving performance. The content length is automatically set if the entire response fits inside the response buffer.

When using HTTP 1.1 chunked encoding (which means that the response has a Transfer-Encoding header), do not set the Content-Length header.

The GET method should be safe, that is, without any side effects for which users are held responsible. For example, most form queries have no side effects. If a client request is intended to change stored data, the request should use some other HTTP method.

The GET method should also be idempotent, meaning that it can be safely repeated. Sometimes making a method safe also makes it idempotent. For example, repeating queries is both safe and idempotent, but buying a product online or modifying data is neither safe nor idempotent.

If the request is incorrectly formatted, doGet returns an HTTP "Bad Request" message. Handle object downloads

Parameters
req:HttpServletRequest

an HttpServletRequest object that contains the request the client has made of the servlet

rsp:HttpServletResponse

an HttpServletResponse object that contains the response the servlet sends to the client

Annotations
@Override
Exceptions
ServletException:
if the request for the GET could not be handled
IOException:
if an input or output error is detected when the servlet handles the GET request
doPutback to summary
protected void doPut(HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException

Overrides jakarta.servlet.http.HttpServlet.doPut.

Doc from jakarta.servlet.http.HttpServlet.doPut.

Called by the server (via the service method) to allow a servlet to handle a PUT request. The PUT operation allows a client to place a file on the server and is similar to sending a file by FTP.

When overriding this method, leave intact any content headers sent with the request (including Content-Length, Content-Type, Content-Transfer-Encoding, Content-Encoding, Content-Base, Content-Language, Content-Location, Content-MD5, and Content-Range). If your method cannot handle a content header, it must issue an error message (HTTP 501 - Not Implemented) and discard the request. For more information on HTTP 1.1 and the PUT method, see RFC 7231 .

This method does not need to be either safe or idempotent. Operations that doPut performs can have side effects for which the user can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage.

If the HTTP PUT request is incorrectly formatted, doPut returns an HTTP "Bad Request" message. Handle object uploads

Parameters
req:HttpServletRequest

the HttpServletRequest object that contains the request the client made of the servlet

rsp:HttpServletResponse

the HttpServletResponse object that contains the response the servlet returns to the client

Annotations
@Override
Exceptions
ServletException:
if the request for the PUT cannot be handled
IOException:
if an input or output error occurs while the servlet is handling the PUT request
getObjectToTransferback to summary
protected AnyLongObjectId getObjectToTransfer(HttpServletRequest req, HttpServletResponse rsp) throws IOException

Retrieve object id from request

Parameters
req:HttpServletRequest

servlet request

rsp:HttpServletResponse

servlet response

Returns:AnyLongObjectId

object id, or null if the object id could not be retrieved

Exceptions
IOException:
if an I/O error occurs
Since
7.0
sendErrorback to summary
protected static void sendError(HttpServletResponse rsp, int status, String message) throws IOException

Send an error response.

Parameters
rsp:HttpServletResponse

the servlet response

status:int

HTTP status code

message:String

error message

Exceptions
IOException:
on failure to send the response
Since
7.0