*/
public class Request {
+ /**
+ * Enumeration for all possible HTTP request methods.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’
+ * Roden</a>
+ */
+ public enum Method {
+
+ /** GET. */
+ GET,
+
+ /** POST. */
+ POST,
+
+ /** PUT. */
+ PUT,
+
+ /** DELETE. */
+ DELETE,
+
+ /** HEAD. */
+ HEAD,
+
+ /** OPTIONS. */
+ OPTIONS,
+
+ /** TRACE. */
+ TRACE,
+
+ }
+
/** The URI that was accessed. */
private final URI uri;
/** The HTTP method that was used. */
- private final String method;
+ private final Method method;
/** The HTTP request. */
private final HTTPRequest httpRequest;
* @param toadletContext
* The toadlet context of the request
*/
- public Request(URI uri, String method, HTTPRequest httpRequest, ToadletContext toadletContext) {
+ public Request(URI uri, Method method, HTTPRequest httpRequest, ToadletContext toadletContext) {
this.uri = uri;
this.method = method;
this.httpRequest = httpRequest;
*
* @return The HTTP method
*/
- public String getMethod() {
+ public Method getMethod() {
return method;
}
import java.net.URI;
import java.util.Map.Entry;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
import freenet.client.HighLevelSimpleClient;
import freenet.clients.http.LinkEnabledCallback;
import freenet.clients.http.Toadlet;
* if the toadlet context is closed
*/
public void handleMethodGET(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
- handleRequest(new Page.Request(uri, "GET", httpRequest, toadletContext));
+ handleRequest(new Page.Request(uri, Method.GET, httpRequest, toadletContext));
}
/**
* if the toadlet context is closed
*/
public void handleMethodPOST(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
- handleRequest(new Page.Request(uri, "POST", httpRequest, toadletContext));
+ handleRequest(new Page.Request(uri, Method.POST, httpRequest, toadletContext));
}
/**