finagle-clojure.http.message
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 MockRequests for service testing purposes.
charset
(charset msg)Gets the charset of the given message.
Arguments:
Returns:
the charset of the message
content-string
(content-string msg)Gets the content string of the given message.
Arguments:
Returns:
the content string of the message
content-type
(content-type msg)Gets the content type of the given message.
Arguments:
Returns:
the content type of the message
header
(header msg header)Gets the named header from the given message.
Arguments:
msg: a com.twitter.finagle.http.Messageheader: a string containing the header name
Returns:
A seq of strings that are the values for the named header in the given message
headers
(headers msg)Returns this message’s headers as a Clojure map.
Arguments:
Returns:
this request’s headers as a Clojure map
http-method
(http-method req)Gets the HTTP method of the given request.
Arguments:
Returns:
the HTTP method of the request as an uppercase string
input-stream
(input-stream msg)Returns this message’s content as an input stream.
Arguments:
Returns:
this request’s content as an input stream
param
(param req param)Returns the named param from the given request.
Arguments:
Returns:
the string contents of the named param
params
(params req)Returns this request’s params as a Clojure map.
Arguments:
Returns:
this request’s params as a Clojure map
request
(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 method
Returns:
an instance of com.twitter.finagle.http.Request, specifically a MockRequest
response
(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 response
Returns:
an instance of com.twitter.finagle.http.Response
set-charset
(set-charset msg charset)Sets the charset of the given message.
Arguments:
msg: a com.twitter.finagle.http.Messagecharset: a string charset
Returns:
the given message
set-content-string
(set-content-string msg content)Sets the content string of the given message.
Arguments:
msg: a com.twitter.finagle.http.Messagecontent: a string of content
Returns:
the given message
set-content-type
(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.Messagetype: a string containing the message’s content-typecharset(optional, default:utf-8): the charset of the content
Returns:
the given message
set-header
(set-header msg name value)Sets the named header in the given message.
Arguments:
msg: a com.twitter.finagle.http.Messagename: a string containing the header namevalue: a stringable object containing the value
Returns:
the given message
set-http-method
(set-http-method req meth)Sets the HTTP method of the given request.
Arguments:
req: a com.twitter.finagle.http.Requestmeth: a string or keyword containing a valid HTTP method
Returns:
the given request
set-status-code
(set-status-code resp code)Sets the status code of the given response.
Arguments:
resp: a com.twitter.finagle.http.Responsecode: a number with the desired HTTP status code
Returns:
the given response
status-code
(status-code resp)Returns the status code of the given Response.
Arguments:
Returns:
the status code of the response as an int