public class HandlerUtil extends Object
HttpServer| Modifier and Type | Method and Description |
|---|---|
static void |
bailResponse(org.apache.http.protocol.HttpContext cx,
org.apache.http.HttpResponse response)
Send and flush the response object over the current connection and close the connection
|
static AuthContext |
getAuth(org.apache.http.protocol.HttpContext cx,
org.apache.http.HttpRequest req)
Get any authorization credentials supplied over the connection.
|
static org.apache.http.HttpServerConnection |
getConnection(org.apache.http.protocol.HttpContext cx)
Get the raw httpcomponents ServerConnection object
|
static com.google.gson.JsonObject |
getJsonQuery(URL url)
Parses a url-encoded query string and
|
static Map<String,String> |
getQueryParams(String s)
Get traditional query parameters as a Java map
|
static Socket |
getSocket(org.apache.http.protocol.HttpContext cx)
Get the underlying raw Socket for this request
|
static URL |
getUrl(org.apache.http.HttpRequest request) |
static void |
make400Response(org.apache.http.HttpResponse response,
String msg)
Sets a 404 not found response with a message
|
static void |
makeJsonResponse(org.apache.http.HttpResponse response,
String encoded)
Sets a JSON encoded response.
|
static void |
makeResponse(org.apache.http.HttpResponse response,
String msg,
int status)
Sets the response body and status
|
static void |
makeStringResponse(org.apache.http.HttpResponse response,
String s)
Sets a string as the response
|
public static org.apache.http.HttpServerConnection getConnection(org.apache.http.protocol.HttpContext cx)
cx - The contextpublic static Socket getSocket(org.apache.http.protocol.HttpContext cx)
cx - The contextpublic static URL getUrl(org.apache.http.HttpRequest request) throws MalformedURLException
request - The requestMalformedURLException - if an error occurspublic static com.google.gson.JsonObject getJsonQuery(URL url) throws MalformedURLException
url - The URL to decodeMalformedURLException - If one of the values is not JSONpublic static Map<String,String> getQueryParams(String s) throws MalformedURLException
s - The query stringMalformedURLException - If the query string is malformed.public static void makeStringResponse(org.apache.http.HttpResponse response,
String s)
response - The response objects - The response bodypublic static void makeResponse(org.apache.http.HttpResponse response,
String msg,
int status)
response - The response objectmsg - The response bodystatus - The response statuspublic static void make400Response(org.apache.http.HttpResponse response,
String msg)
response - The response objectmsg - The messagepublic static void makeJsonResponse(org.apache.http.HttpResponse response,
String encoded)
Content-Type header will be set to application/jsonresponse - The response objectencoded - The JSON-encoded stringpublic static void bailResponse(org.apache.http.protocol.HttpContext cx,
org.apache.http.HttpResponse response)
throws IOException,
org.apache.http.HttpException
cx - The contextresponse - The response objectIOException - if an I/O error occursorg.apache.http.HttpException - if a http error occurspublic static AuthContext getAuth(org.apache.http.protocol.HttpContext cx, org.apache.http.HttpRequest req) throws IOException
cx - The HTTP Context (from httpcomonents)req - The requestIOException - if an I/O error occursCopyright © 2017. All rights reserved.