Repository navigation
Expand file tree
/
Copy pathRequestHandler.java
More file actions
87 lines (80 loc) · 3.08 KB
/
Copy pathRequestHandler.java
File metadata and controls
87 lines (80 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package me.desair.tus.server;
import java.io.IOException;
import me.desair.tus.server.exception.TusException;
import me.desair.tus.server.upload.UploadLockingService;
import me.desair.tus.server.upload.UploadStorageService;
import me.desair.tus.server.util.TusServletRequest;
import me.desair.tus.server.util.TusServletResponse;
/** Interface for processing HTTP request logic within protocol extensions. */
public interface RequestHandler {
/**
* Test if this request handler supports the given HTTP method.
*
* @param method The current HTTP method
* @return true if supported, false otherwise
*/
boolean supports(HttpMethod method);
/**
* Process the given HTTP request.
*
* @param method The HTTP method of this request
* @param servletRequest The HTTP request
* @param servletResponse The HTTP response
* @param uploadStorageService The current upload storage service
* @param ownerKey Identifier of the owner of this upload
* @throws IOException When an I/O error occurs
* @throws TusException When a protocol error occurs
*/
default void process(
HttpMethod method,
TusServletRequest servletRequest,
TusServletResponse servletResponse,
UploadStorageService uploadStorageService,
String ownerKey)
throws IOException, TusException {
throw new UnsupportedOperationException(
"This method is deprecated and should not be called. Implement process(7 args) instead.");
}
/**
* Process the given HTTP request with access to the upload locking service and the exception.
*
* @param method The HTTP method of this request
* @param servletRequest The HTTP request
* @param servletResponse The HTTP response
* @param uploadStorageService The current upload storage service
* @param uploadLockingService The upload locking service instance
* @param ownerKey Identifier of the owner of this upload
* @param exception The exception that occurred
* @return An optional HttpProblemDetails to write to the response
* @throws IOException When an I/O error occurs
* @throws TusException When a protocol error occurs
*/
default HttpProblemDetails process(
HttpMethod method,
TusServletRequest servletRequest,
TusServletResponse servletResponse,
UploadStorageService uploadStorageService,
UploadLockingService uploadLockingService,
String ownerKey,
TusException exception)
throws IOException, TusException {
process(method, servletRequest, servletResponse, uploadStorageService, ownerKey);
return null;
}
/**
* Test if this handler is an error handler invoked during exception processing.
*
* @return true if this handler processes errors, false otherwise
*/
boolean isErrorHandler();
/**
* Test if this request handler supports the given HTTP method and protocol version
*
* @param method The current HTTP method
* @param version The protocol version of the request
* @return true if supported, false otherwise
*/
default boolean supports(HttpMethod method, ProtocolVersion version) {
return supports(method);
}
}