Package io.sockit.gameserver
Class WebResource
java.lang.Object
io.sockit.gameserver.WebResource
public class WebResource extends Object
An instance of this class represents a web resource that will be sent by the server to the web client such as your web browser.
-
Constructor Summary
Constructors Constructor Description WebResource()
Constructs a new empty Web Resource - without any bodyWebResource(File file)
Constructs a new Web Resource with the specified File's content as the input of the web resource.WebResource(File file, String mimeType)
Constructs a new Web Resource with the specified File's content as the input/source of the web resource.WebResource(InputStream inputStream, String mimeType, long byteCount)
Constructs a new Web Resource with the specified byte stream as the input/source of the web resource. -
Method Summary
Modifier and Type Method Description void
addHttpResponseHeader(String name, String value)
Add an http response header to this resource.static String
getMimeType(String fileExtension)
Returns the mime type for the specified file extensionvoid
setHttpResponseStatus(int httpResponseStatusCode)
Sets the http response status code of this resource
-
Constructor Details
-
WebResource
public WebResource()Constructs a new empty Web Resource - without any body -
WebResource
Constructs a new Web Resource with the specified File's content as the input of the web resource. The resource mime type will be resolved from the file extension. for eg. if the extension is .html then the mime type will be 'text/html'- Parameters:
file
- - the file which is the input of the web resource
-
WebResource
Constructs a new Web Resource with the specified File's content as the input/source of the web resource.- Parameters:
file
- - the file which is the input of the web resourcemimeType
- - the mime type of the resource
-
WebResource
Constructs a new Web Resource with the specified byte stream as the input/source of the web resource.- Parameters:
inputStream
- - byte stream which is the input of the web resourcemimeType
- - the mime type of the resourcebyteCount
- - the total number of bytes in the byte stream
-
-
Method Details
-
getMimeType
Returns the mime type for the specified file extension- Parameters:
fileExtension
- - the file extension- Returns:
- - the mime type
-
addHttpResponseHeader
Add an http response header to this resource. This header will be added to the http response sent to the web client- Parameters:
name
- - the header namevalue
- - the header value
-
setHttpResponseStatus
public void setHttpResponseStatus(int httpResponseStatusCode)Sets the http response status code of this resource- Parameters:
httpResponseStatusCode
- - the http response status code of this resource
-