Package septogeddon.pluginquery.http
Class ProtocolClient
java.lang.Object
java.io.OutputStream
septogeddon.pluginquery.http.ProtocolClient
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
The client, or the browser who requested the http. This is also an OutputStream.
-
Constructor Summary
ConstructorsConstructorDescriptionProtocolClient(String version, HTTPContext httpContext, io.netty.channel.ChannelHandlerContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Send HTTP response to the client andflush()the buffervoidflush()Send the buffer to the client and flush it from the memoryGet header valueMap of headersGet the HTTP Context for this client requestintGet the response code.Get the response text.Get the protocol version.voidSet header for this responsevoidsetResponseCode(int responseCode) Set the response code for the responsevoidsetResponseText(String responseText) Set the response text (description)voidsetVersion(String version) Set specific version for the responsevoidwrite(byte[] b) Initialize and send HTTP response and write the bytes to the memory buffer.voidwrite(byte[] b, int off, int len) Initialize and send HTTP response and write the bytes to the memory buffer.voidwrite(int b) Initialize and send HTTP response and write byte to the memory buffer.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ProtocolClient
public ProtocolClient(String version, HTTPContext httpContext, io.netty.channel.ChannelHandlerContext context)
-
-
Method Details
-
getVersion
Get the protocol version. (i.e. HTTP/1.1)- Returns:
- the protocol version
-
getResponseCode
public int getResponseCode()Get the response code. (i.e. 200 for OK)- Returns:
- the code
-
getResponseText
Get the response text. (i.e. "OK" for response code 200)- Returns:
- the text
-
setVersion
Set specific version for the response- Parameters:
version- the protocol version
-
setResponseCode
public void setResponseCode(int responseCode) Set the response code for the response- Parameters:
responseCode- the code
-
setResponseText
Set the response text (description)- Parameters:
responseText- the text description
-
getHeaders
Map of headers- Returns:
- headers
-
getHTTPContext
Get the HTTP Context for this client request- Returns:
- HTTPContext instance
-
setHeader
Set header for this response- Parameters:
key- the header namevalue- the header value
-
getHeader
Get header value- Parameters:
name- the header name- Returns:
- the header value
-
write
public void write(int b) Initialize and send HTTP response and write byte to the memory buffer. Once this method called, you cannot modify the response header (e.g.setHeader(String, Object),setResponseCode(int), etc)- Specified by:
writein classOutputStream- Parameters:
b- the byte
-
write
public void write(byte[] b) Initialize and send HTTP response and write the bytes to the memory buffer. Once this method called, you cannot modify the response header (e.g.setHeader(String, Object),setResponseCode(int), etc)- Overrides:
writein classOutputStream- Parameters:
b- the bytes
-
write
public void write(byte[] b, int off, int len) Initialize and send HTTP response and write the bytes to the memory buffer. Once this method called, you cannot modify the response header (e.g.setHeader(String, Object),setResponseCode(int), etc)- Overrides:
writein classOutputStream- Parameters:
b- the byte arrayoff- the offsetlen- the array length
-
flush
public void flush()Send the buffer to the client and flush it from the memory- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream
-
close
public void close()Send HTTP response to the client andflush()the buffer- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-