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
ConstructorDescriptionProtocolClient
(String version, HTTPContext httpContext, io.netty.channel.ChannelHandlerContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Send HTTP response to the client andflush()
the buffervoid
flush()
Send the buffer to the client and flush it from the memoryGet header valueMap of headersGet the HTTP Context for this client requestint
Get the response code.Get the response text.Get the protocol version.void
Set header for this responsevoid
setResponseCode
(int responseCode) Set the response code for the responsevoid
setResponseText
(String responseText) Set the response text (description)void
setVersion
(String version) Set specific version for the responsevoid
write
(byte[] b) Initialize and send HTTP response and write the bytes to the memory buffer.void
write
(byte[] b, int off, int len) Initialize and send HTTP response and write the bytes to the memory buffer.void
write
(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:
write
in 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:
write
in 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:
write
in 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:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
-
close
public void close()Send HTTP response to the client andflush()
the buffer- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
-