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 Details

    • WebResource

      public WebResource()
      Constructs a new empty Web Resource - without any body
    • WebResource

      public WebResource​(File file)
      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

      public WebResource​(File file, String mimeType)
      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 resource
      mimeType - - the mime type of the resource
    • WebResource

      public 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.
      Parameters:
      inputStream - - byte stream which is the input of the web resource
      mimeType - - the mime type of the resource
      byteCount - - the total number of bytes in the byte stream
  • Method Details

    • getMimeType

      public static final String getMimeType​(String fileExtension)
      Returns the mime type for the specified file extension
      Parameters:
      fileExtension - - the file extension
      Returns:
      - the mime type
    • addHttpResponseHeader

      public void addHttpResponseHeader​(String name, String value)
      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 name
      value - - 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