Functions for working with [[com.twitter.finagle.http.Message]] and its concrete subclasses, [[com.twitter.finagle.http.Request]] and [[com.twitter.finagle.http.Response]].
Request
objects are passed to services bound to a Finagle HTTP server, and Response
objects must be passed back
(wrapped in a Future
) in turn. Most requests are constructed by Finagle, but the functions here to may be helpful
to create MockRequest
s for service testing purposes.
Functions for working with [[com.twitter.finagle.http.Message]] and its concrete subclasses, [[com.twitter.finagle.http.Request]] and [[com.twitter.finagle.http.Response]]. `Request` objects are passed to services bound to a Finagle HTTP server, and `Response` objects must be passed back (wrapped in a `Future`) in turn. Most requests are constructed by Finagle, but the functions here to may be helpful to create `MockRequest`s for service testing purposes.
(charset msg)
Gets the charset of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]Returns:
the charset of the message
Gets the charset of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] *Returns*: the charset of the message
(content-string msg)
Gets the content string of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]Returns:
the content string of the message
Gets the content string of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] *Returns*: the content string of the message
(content-type msg)
Gets the content type of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]Returns:
the content type of the message
Gets the content type of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] *Returns*: the content type of the message
(header msg header)
Gets the named header from the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]header
: a string containing the header nameReturns:
A seq of strings that are the values for the named header in the given message
Gets the named header from the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] * `header`: a string containing the header name *Returns*: A seq of strings that are the values for the named header in the given message
(headers msg)
Returns this message's headers as a Clojure map.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]Returns:
this request's headers as a Clojure map
Returns this message's headers as a Clojure map. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] *Returns*: this request's headers as a Clojure map
(http-method req)
Gets the HTTP method of the given request.
Arguments:
req
: a [[com.twitter.finagle.http.Request]]Returns:
the HTTP method of the request as an uppercase string
Gets the HTTP method of the given request. *Arguments*: * `req`: a [[com.twitter.finagle.http.Request]] *Returns*: the HTTP method of the request as an uppercase string
(input-stream msg)
Returns this message's content as an input stream.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]Returns:
this request's content as an input stream
Returns this message's content as an input stream. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] *Returns*: this request's content as an input stream
(param req param)
Returns the named param from the given request.
Arguments:
req
: a [[com.twitter.finagle.http.Request]]Returns:
the string contents of the named param
Returns the named param from the given request. *Arguments*: * `req`: a [[com.twitter.finagle.http.Request]] *Returns*: the string contents of the named param
(params req)
Returns this request's params as a Clojure map.
Arguments:
req
: a [[com.twitter.finagle.http.Request]]Returns:
this request's params as a Clojure map
Returns this request's params as a Clojure map. *Arguments*: * `req`: a [[com.twitter.finagle.http.Request]] *Returns*: this request's params as a Clojure map
(request uri)
(request uri method)
Constructs a Request
. Usually this will be constructed on your behalf for incoming requests;
this function is useful primarily testing purposes, and indeed returns a MockRequest
in its current form.
Arguments:
uri
: the URI of the requestmethod
(optional): a keyword or string of the desired HTTP methodReturns:
an instance of [[com.twitter.finagle.http.Request]], specifically a MockRequest
Constructs a `Request`. Usually this will be constructed on your behalf for incoming requests; this function is useful primarily testing purposes, and indeed returns a `MockRequest` in its current form. *Arguments*: * `uri`: the URI of the request * `method` (optional): a keyword or string of the desired HTTP method *Returns*: an instance of [[com.twitter.finagle.http.Request]], specifically a MockRequest
(response)
(response code)
Constructs a Response
, required for Finagle services that interact with an HttpServer
.
Arguments:
code
(optional): a number representing the desired HTTP status code of the responseReturns:
an instance of [[com.twitter.finagle.http.Response]]
Constructs a `Response`, required for Finagle services that interact with an `HttpServer`. *Arguments*: * `code` (optional): a number representing the desired HTTP status code of the response *Returns*: an instance of [[com.twitter.finagle.http.Response]]
(set-charset msg charset)
Sets the charset of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]charset
: a string charsetReturns:
the given message
Sets the charset of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] * `charset`: a string charset *Returns*: the given message
(set-content-string msg content)
Sets the content string of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]content
: a string of contentReturns:
the given message
Sets the content string of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] * `content`: a string of content *Returns*: the given message
(set-content-type msg type)
(set-content-type msg type charset)
Sets the content type of the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]type
: a string containing the message's content-typecharset
(optional, default: utf-8
): the charset of the contentReturns:
the given message
Sets the content type of the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] * `type`: a string containing the message's content-type * `charset` (optional, default: `utf-8`): the charset of the content *Returns*: the given message
(set-header msg name value)
Sets the named header in the given message.
Arguments:
msg
: a [[com.twitter.finagle.http.Message]]name
: a string containing the header namevalue
: a stringable object containing the valueReturns:
the given message
Sets the named header in the given message. *Arguments*: * `msg`: a [[com.twitter.finagle.http.Message]] * `name`: a string containing the header name * `value`: a stringable object containing the value *Returns*: the given message
(set-http-method req meth)
Sets the HTTP method of the given request.
Arguments:
req
: a [[com.twitter.finagle.http.Request]]meth
: a string or keyword containing a valid HTTP methodReturns:
the given request
Sets the HTTP method of the given request. *Arguments*: * `req`: a [[com.twitter.finagle.http.Request]] * `meth`: a string or keyword containing a valid HTTP method *Returns*: the given request
(set-status-code resp code)
Sets the status code of the given response.
Arguments:
resp
: a [[com.twitter.finagle.http.Response]]code
: a number with the desired HTTP status codeReturns:
the given response
Sets the status code of the given response. *Arguments*: * `resp`: a [[com.twitter.finagle.http.Response]] * `code`: a number with the desired HTTP status code *Returns*: the given response
(status-code resp)
Returns the status code of the given Response
.
Arguments:
resp
: a [[com.twitter.finagle.http.Response]]Returns:
the status code of the response as an int
Returns the status code of the given `Response`. *Arguments*: * `resp`: a [[com.twitter.finagle.http.Response]] *Returns*: the status code of the response as an int
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close