Package org.astrogrid.samp.httpd
Class HttpServer.Request
- java.lang.Object
-
- org.astrogrid.samp.httpd.HttpServer.Request
-
- Enclosing class:
- HttpServer
public static class HttpServer.Request extends java.lang.Object
Represents a parsed HTTP client request.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
body_
private java.util.Map
headerMap_
private java.lang.String
method_
private java.net.SocketAddress
remoteAddress_
private java.lang.String
url_
-
Constructor Summary
Constructors Constructor Description Request(java.lang.String method, java.lang.String url, java.util.Map headerMap, java.net.SocketAddress remoteAddress, byte[] body)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getBody()
Returns the body of the HTTP request if there was one.java.util.Map
getHeaderMap()
Returns a map of key-value pairs representing HTTP request headers.java.lang.String
getMethod()
Returns the request method string.java.net.SocketAddress
getRemoteAddress()
Returns the address of the client which made this request.java.lang.String
getUrl()
Returns the request URL string.java.lang.String
toString()
-
-
-
Constructor Detail
-
Request
public Request(java.lang.String method, java.lang.String url, java.util.Map headerMap, java.net.SocketAddress remoteAddress, byte[] body)
Constructor.- Parameters:
method
- HTTP method string (GET, HEAD etc)url
- requested URL path (should start "/")headerMap
- map of HTTP request header key-value pairsremoteAddress
- address of the client making the requestbody
- bytes comprising request body, or null if none present
-
-
Method Detail
-
getMethod
public java.lang.String getMethod()
Returns the request method string.- Returns:
- GET, HEAD, or whatever
-
getUrl
public java.lang.String getUrl()
Returns the request URL string. This should be a path starting "/" (the hostname part is not present).- Returns:
- url path
-
getHeaderMap
public java.util.Map getHeaderMap()
Returns a map of key-value pairs representing HTTP request headers. Note that for HTTP usage, header keys are case-insensitive (RFC2616 sec 4.2); theHttpServer.getHeader(java.util.Map, java.lang.String)
utility method can be used to interrogate the returned map.- Returns:
- header map
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress()
Returns the address of the client which made this request.- Returns:
- requesting client's socket address
-
getBody
public byte[] getBody()
Returns the body of the HTTP request if there was one.- Returns:
- body bytes or null
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-