public class HttpServerConnection extends Object implements HandshakeCompletedListener
Constructor and Description |
---|
HttpServerConnection(Socket socket,
String encoding,
HttpConnector connector) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected HttpRequest |
createHttpRequest() |
String |
getFullUri() |
InputStream |
getInputStream() |
Certificate[] |
getLocalCertificateChain() |
OutputStream |
getOutputStream() |
Certificate[] |
getPeerCertificateChain() |
String |
getRemoteClientAddress() |
RequestLine |
getRequestLine() |
int |
getSocketReceiveBufferSize()
Gets the value of the SO_RCVBUF for the underlying socket.
|
int |
getSocketTimeout()
Returns the value of the SO_TIMEOUT for the underlying socket.
|
Latch |
getSslSocketHandshakeCompleteLatch() |
String |
getUrlWithoutRequestParams()
Returns the path of the http request without the http parameters encoded in the URL
|
ResponseWriter |
getWriter()
Returns the ResponseWriter used to write the output to the socket.
|
void |
handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) |
boolean |
isKeepAlive() |
boolean |
isOpen() |
boolean |
isSocketKeepAlive()
Tests if SO_KEEPALIVE is enabled in the underlying socket.
|
boolean |
isSocketTcpNoDelay()
Tests if TCP_NODELAY is enabled in the underlying socket.
|
HttpRequest |
readRequest() |
HttpResponse |
readResponse() |
void |
reset()
Clean up cached values.
|
void |
setKeepAlive(boolean b) |
void |
setSocketTimeout(int timeout) |
void |
writeFailureResponse(int statusCode,
String description)
Sends to the customer a Failure response.
|
void |
writeFailureResponse(int statusCode,
String description,
Map<String,String> headers)
Sends a customer a failure response but also adds the headers in the headers map
|
void |
writeRequest(HttpRequest request) |
void |
writeResponse(HttpResponse response) |
void |
writeResponse(HttpResponse response,
Map<String,String> headers)
Write an HttpResponse and add the map entries as headers
|
public HttpServerConnection(Socket socket, String encoding, HttpConnector connector) throws IOException
IOException
public void close()
public boolean isOpen()
public void setKeepAlive(boolean b)
public boolean isKeepAlive()
public InputStream getInputStream()
public OutputStream getOutputStream()
public ResponseWriter getWriter() throws UnsupportedEncodingException
UnsupportedEncodingException
public HttpRequest readRequest() throws IOException
IOException
protected HttpRequest createHttpRequest() throws IOException
IOException
public HttpResponse readResponse() throws IOException
IOException
public void writeRequest(HttpRequest request) throws IOException
IOException
public void writeResponse(HttpResponse response) throws IOException
IOException
public void writeResponse(HttpResponse response, Map<String,String> headers) throws IOException
response
- http response with the content of the responseheaders
- headers to add to the http response besides the one already contained in the HttpResponse objectIOException
public String getUrlWithoutRequestParams() throws IOException
IOException
public String getRemoteClientAddress()
public void writeFailureResponse(int statusCode, String description) throws IOException
statusCode
- http status code to send to the clientdescription
- description to send as the body of the responseIOException
- when it's not possible to write the response back to the client.public void writeFailureResponse(int statusCode, String description, Map<String,String> headers) throws IOException
statusCode
- status code of the failure responsedescription
- message to be send as the bodyheaders
- headers to send with the failure responseIOException
public String getFullUri() throws IOException
IOException
public int getSocketTimeout() throws SocketException
SocketException
- If there is an error in the underlying protocol.public void setSocketTimeout(int timeout) throws SocketException
SocketException
public boolean isSocketKeepAlive() throws SocketException
boolean
indicating whether or not SO_KEEPALIVE is enabled.SocketException
- If there is an error in the underlying protocol.public boolean isSocketTcpNoDelay() throws SocketException
boolean
indicating whether or not TCP_NODELAY is enabled.SocketException
- If there is an error in the underlying protocol.public int getSocketReceiveBufferSize() throws SocketException
SocketException
- If there is an error in the underlying protocol.public Latch getSslSocketHandshakeCompleteLatch()
public void reset() throws IOException
IOException
public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent)
handshakeCompleted
in interface HandshakeCompletedListener
public Certificate[] getLocalCertificateChain()
public Certificate[] getPeerCertificateChain()
public RequestLine getRequestLine() throws IOException
IOException
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.