HttpResponse

scurry.http.HttpResponse
class HttpResponse extends HttpMessage

Encapsulates HTTP response.

Attributes

Graph
Supertypes
class HttpMessage
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Constructors

def this(res: Map[String, AnyRef])

Creates HTTP response from supplied response.

Creates HTTP response from supplied response.

import java.time.Instant
import scurry.http.HttpResponse

def now = Instant.now()
def file = './path/to/example.json' as File
def lastModified = file.lastModified()

def response = new HttpResponse(
  statusCode: 200,
  headers: [
    "Content-Type": "application/json",
    "Content-Length": file.size(),
    "Last-Modified": Instant.ofEpochMilli(lastModified),
    "Date": now
  ],
  cookies: [
   [
     name: "sessionid",
     value: "230148A1-030E-4680-B55E-743B6ABBA6FA",
     domain: ".example.com",
     secure: true,
     expires: now + 300
   ],
   [name: "region", value: "us-se", domain: ".example.com"]
  ],
  // Supply body as Array[Byte], String, File, Path, InputStream, Reader,
  // QueryString, Multipart, or BodyWriter
  body: file
)

Attributes

See also

Concrete methods

Gets cookies.

Gets cookies.

Attributes

def getReasonPhrase(): String

Gets reason phrase.

Gets reason phrase.

Attributes

def getStatusCode(): Int

Gets status code.

Gets status code.

Attributes

def isClientError(): Boolean

Tests for client error status code.

Tests for client error status code.

Attributes

def isInformational(): Boolean

Tests for informational status code.

Tests for informational status code.

Attributes

def isRedirection(): Boolean

Tests for redirection status code.

Tests for redirection status code.

Attributes

def isServerError(): Boolean

Tests for server error status code.

Tests for server error status code.

Attributes

def isSuccessful(): Boolean

Tests for successful status code.

Tests for successful status code.

Attributes

Inherited methods

def getBody(): Body

Gets message body.

Gets message body.

Attributes

Inherited from:
HttpMessage

Gets message headers.

Gets message headers.

Attributes

Inherited from:
HttpMessage
def getHttpVersion(): String

Gets HTTP version.

Gets HTTP version.

Attributes

Inherited from:
HttpMessage
def getStartLine(): String

Gets message start line.

Gets message start line.

Attributes

Inherited from:
HttpMessage