Interface IResponse

All Known Implementing Classes:
Response

public interface IResponse
An interface for Response. Built to enable easier testing on web handlers.
  • Method Details

    • getExtraHeaders

      Headers getExtraHeaders()
      Any extra headers set on the Response by the developer
    • getStatusCode

      StatusLine.StatusCode getStatusCode()
      The StatusLine.StatusCode set by the developer for this Response.
    • isBodyText

      boolean isBodyText()
      Whether the body is text (rather than binary) If true, a method like Response.buildResponse(StatusLine.StatusCode, Map, String) was used, meaning the body would benefit from compression (if large enough to warrant the performance hit from compressing it)
    • getBodyLength

      long getBodyLength()
      Gets the length of the body for this response. If the body is an array of bytes set by the user, we grab this value by the length() method. If the outgoing data is set by a lambda, the user will set the bodyLength value.
    • sendBody

      void sendBody(ISocketWrapper sw) throws Exception
      By calling this method with a ISocketWrapper parameter, the method will send bytes on the associated socket.
      Throws:
      Exception - so that when this is called in WebFramework.httpProcessing(ISocketWrapper), the exception type can be examined and some IOException types like SocketException can be recorded more quietly, instead of rendering a whole stack trace in the logs.
    • getBody

      byte[] getBody()
      Returns the bytes of the Response body being sent to the client