mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-27 20:58:40 +01:00
Added helper classes for HTTP.
This commit is contained in:
parent
060d1092f9
commit
e900aca2e0
20
src/main/java/org/dynmap/web/HttpErrorHandler.java
Normal file
20
src/main/java/org/dynmap/web/HttpErrorHandler.java
Normal file
@ -0,0 +1,20 @@
|
||||
package org.dynmap.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpErrorHandler {
|
||||
public static void handle(HttpResponse response, int statusCode, String statusMessage) throws IOException {
|
||||
response.statusCode = statusCode;
|
||||
response.statusMessage = statusMessage;
|
||||
response.fields.put("Content-Length", "0");
|
||||
response.getBody();
|
||||
}
|
||||
|
||||
public static void handleNotFound(HttpResponse response) throws IOException {
|
||||
handle(response, 404, "Not found");
|
||||
}
|
||||
|
||||
public static void handleMethodNotAllowed(HttpResponse response) throws IOException {
|
||||
handle(response, 405, "Method not allowed");
|
||||
}
|
||||
}
|
8
src/main/java/org/dynmap/web/HttpMethods.java
Normal file
8
src/main/java/org/dynmap/web/HttpMethods.java
Normal file
@ -0,0 +1,8 @@
|
||||
package org.dynmap.web;
|
||||
|
||||
public class HttpMethods {
|
||||
public static final String Get = "GET";
|
||||
public static final String Post = "POST";
|
||||
public static final String Put = "PUT";
|
||||
public static final String Delete = "DELETE";
|
||||
}
|
Loading…
Reference in New Issue
Block a user