Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package twitter

    Start with com.twitter.finagle.

    Definition Classes
    com
  • package finagle

    Finagle is an extensible RPC system.

    Finagle is an extensible RPC system.

    Services are represented by class com.twitter.finagle.Service. Clients make use of com.twitter.finagle.Service objects while servers implement them.

    Finagle contains a number of protocol implementations; each of these implement Client and/or com.twitter.finagle.Server. For example, Finagle's HTTP implementation, com.twitter.finagle.Http (in package finagle-http), exposes both.

    Thus a simple HTTP server is built like this:

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Await, Future}
    
    val service = new Service[Request, Response] {
      def apply(req: Request): Future[Response] =
        Future.value(Response())
    }
    val server = Http.server.serve(":8080", service)
    Await.ready(server)

    We first define a service to which requests are dispatched. In this case, the service returns immediately with a HTTP 200 OK response, and with no content.

    This service is then served via the Http protocol on TCP port 8080. Finally we wait for the server to stop serving.

    We can now query our web server:

    % curl -D - localhost:8080
    HTTP/1.1 200 OK

    Building an HTTP client is also simple. (Note that type annotations are added for illustration.)

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Future, Return, Throw}
    
    val client: Service[Request, Response] = Http.client.newService("localhost:8080")
    val f: Future[Response] = client(Request()).respond {
      case Return(rep) =>
        printf("Got HTTP response %s\n", rep)
      case Throw(exc) =>
        printf("Got error %s\n", exc)
    }

    Http.client.newService("localhost:8080") constructs a new com.twitter.finagle.Service instance connected to localhost TCP port 8080. We then issue a HTTP/1.1 GET request to URI "/". The service returns a com.twitter.util.Future representing the result of the operation. We listen to this future, printing an appropriate message when the response arrives.

    The Finagle homepage contains useful documentation and resources for using Finagle.

    Definition Classes
    twitter
  • package http
    Definition Classes
    finagle
  • object Request
    Definition Classes
    http
  • Proxy

abstract class Proxy extends Request

Proxy for Request. This can be used to create a richer request class that wraps Request without exposing the underlying netty http type.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Proxy
  2. Request
  3. Message
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Proxy()

Abstract Value Members

  1. abstract def request: Request

    Underlying Request

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def accept: Seq[String]

    Accept header

    Accept header

    Definition Classes
    Message
  5. def acceptMediaTypes: Seq[String]

    Accept header media types (normalized, no parameters)

    Accept header media types (normalized, no parameters)

    Definition Classes
    Message
  6. def accept_=(values: Iterable[String]): Unit

    Set Accept header with list of values

    Set Accept header with list of values

    Definition Classes
    Message
  7. def accept_=(value: String): Unit

    Set Accept header

    Set Accept header

    Definition Classes
    Message
  8. def addCookie(cookie: Cookie): Unit

    Add a cookie

    Add a cookie

    Definition Classes
    Message
  9. def allow: Option[String]

    Allow header

    Allow header

    Definition Classes
    Message
  10. def allow_=(values: Iterable[Method]): Unit

    Set Authorization header

    Set Authorization header

    Definition Classes
    Message
  11. def allow_=(value: String): Unit

    Set Authorization header

    Set Authorization header

    Definition Classes
    Message
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def authorization: Option[String]

    Get Authorization header

    Get Authorization header

    Definition Classes
    Message
  14. def authorization_=(value: String): Unit

    Set Authorization header

    Set Authorization header

    Definition Classes
    Message
  15. def cacheControl: Option[String]

    Get Cache-Control header

    Get Cache-Control header

    Definition Classes
    Message
  16. def cacheControl_=(maxAge: Duration): Unit

    Set Cache-Control header with a max-age (and must-revalidate).

    Set Cache-Control header with a max-age (and must-revalidate).

    Definition Classes
    Message
  17. def cacheControl_=(value: String): Unit

    Set Cache-Control header

    Set Cache-Control header

    Definition Classes
    Message
  18. def charset: Option[String]

    Get charset from Content-Type header

    Get charset from Content-Type header

    Definition Classes
    Message
  19. def charset_=(value: String): Unit

    Set charset in Content-Type header.

    Set charset in Content-Type header. This does not change the content.

    Definition Classes
    Message
  20. final def clearContent(): Unit

    Clear content (set to "").

    Clear content (set to "").

    Definition Classes
    Message
  21. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  22. def close(): Future[Unit]

    End the response stream.

    End the response stream.

    Definition Classes
    Message
  23. def containsParam(name: String): Boolean

    Check if parameter exists.

    Check if parameter exists.

    Definition Classes
    Request
  24. final def content: Buf

    Retrieve the current content of this Message.

    Retrieve the current content of this Message.

    If this message is chunked, the resulting Buf will always be empty.

    Definition Classes
    ProxyMessage
  25. final def content(content: Buf): Proxy.this.type

    Set the content of this Message.

    Set the content of this Message.

    Any existing content is discarded. If this Message is set to chunked, an IllegalStateException is thrown.

    Definition Classes
    Message
    Annotations
    @throws( ... )
    See also

    content_=(Buf) for Scala users

  26. final def contentLength(value: Long): Proxy.this.type

    Set Content-Length header.

    Set Content-Length header. Normally, this is automatically set by the Codec, but this method allows you to override that.

    Definition Classes
    Message
    See also

    contentLength_=(Long) for Scala users.

  27. def contentLength: Option[Long]

    Get the value of the Content-Length header.

    Get the value of the Content-Length header. Use length to get the length of actual content.

    Definition Classes
    Message
    See also

    Long for Java users.

  28. final def contentLengthOrElse(default: Long): Long

    Get the value of the Content-Length header, or the provided default if it doesn't exist.

    Get the value of the Content-Length header, or the provided default if it doesn't exist.

    Definition Classes
    Message
    See also

    Option(Long) for Scala users.

  29. def contentLength_=(value: Long): Unit

    Set Content-Length header.

    Set Content-Length header. Normally, this is automatically set by the Codec, but this method allows you to override that.

    Definition Classes
    Message
    See also

    contentLength(Long) for Java users.

  30. def contentString: String

    Get the content as a string.

    Get the content as a string.

    Definition Classes
    Message
  31. def contentString_=(value: String): Unit

    Set the content as a string.

    Set the content as a string.

    Definition Classes
    Message
  32. def contentType: Option[String]

    Get Content-Type header

    Get Content-Type header

    Definition Classes
    Message
  33. def contentType_=(value: String): Unit

    Set Content-Type header

    Set Content-Type header

    Definition Classes
    Message
  34. final def content_=(content: Buf): Unit

    Set the content of this Message.

    Set the content of this Message.

    Any existing content is discarded. If this Message is set to chunked, an IllegalStateException is thrown.

    Definition Classes
    ProxyMessage
    See also

    content(Buf) for Java users

  35. lazy val cookies: CookieMap

    Cookies.

    Cookies. In a request, this uses the Cookie headers. In a response, it uses the Set-Cookie headers.

    Definition Classes
    ProxyMessage
  36. def ctx: Record

    Arbitrary user-defined context associated with this request object.

    Arbitrary user-defined context associated with this request object. RecordSchema.Record is used here, rather than Context or similar out-of-band mechanisms, to make the connection between the request and its associated context explicit.

    Definition Classes
    ProxyRequest
  37. def date: Option[String]

    Get Date header

    Get Date header

    Definition Classes
    Message
  38. def date_=(value: Date): Unit

    Set Date header by Date

    Set Date header by Date

    Definition Classes
    Message
  39. def date_=(value: String): Unit

    Set Date header

    Set Date header

    Definition Classes
    Message
  40. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  41. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  42. def expires: Option[String]

    Get Expires header

    Get Expires header

    Definition Classes
    Message
  43. def expires_=(value: Date): Unit

    Set Expires header by Date

    Set Expires header by Date

    Definition Classes
    Message
  44. def expires_=(value: String): Unit

    Set Expires header

    Set Expires header

    Definition Classes
    Message
  45. def fileExtension: String

    File extension.

    File extension. Empty string if none.

    Definition Classes
    Request
    Annotations
    @BeanProperty()
  46. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  47. def getBooleanParam(name: String, default: Boolean): Boolean

    Get Boolean param.

    Get Boolean param. Returns value or default.

    Definition Classes
    Request
  48. def getBooleanParam(name: String): Boolean

    Get Boolean param.

    Get Boolean param. Returns value or false.

    Definition Classes
    Request
  49. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  50. def getContentString(): String
    Definition Classes
    Message
  51. def getCookies(): Iterator[Cookie]

    Get iterator over Cookies

    Get iterator over Cookies

    Definition Classes
    Message
  52. final def getInputStream(): InputStream

    Get InputStream for content.

    Get InputStream for content. Caller must close. (Java interface. Scala users should use withInputStream.)

    Definition Classes
    Message
  53. def getIntParam(name: String, default: Int): Int

    Get Int param.

    Get Int param. Returns value or default.

    Definition Classes
    Request
  54. def getIntParam(name: String): Int

    Get Int param.

    Get Int param. Returns value or 0.

    Definition Classes
    Request
  55. final def getLength(): Int

    Get length of content.

    Get length of content.

    Definition Classes
    Message
  56. def getLongParam(name: String, default: Long): Long

    Get Long param.

    Get Long param. Returns value or default.

    Definition Classes
    Request
  57. def getLongParam(name: String): Long

    Get Long param.

    Get Long param. Returns value or 0.

    Definition Classes
    Request
  58. def getParam(name: String, default: String): String

    Get parameter value.

    Get parameter value. Returns value or default.

    Definition Classes
    Request
  59. def getParam(name: String): String

    Get parameter value.

    Get parameter value. Returns value or null.

    Definition Classes
    Request
  60. def getParamNames(): Set[String]

    Get parameters names.

    Get parameters names.

    Definition Classes
    Request
  61. def getParams(): List[Entry[String, String]]

    Get all parameters.

    Get all parameters.

    Definition Classes
    Request
  62. def getParams(name: String): List[String]

    Get all values of parameter.

    Get all values of parameter. Returns list of values.

    Definition Classes
    Request
  63. final def getReader(): Reader

    Get Reader for content.

    Get Reader for content. (Java interface. Scala users should use withReader.)

    Definition Classes
    Message
  64. def getShortParam(name: String, default: Short): Short

    Get Short param.

    Get Short param. Returns value or default.

    Definition Classes
    Request
  65. def getShortParam(name: String): Short

    Get Short param.

    Get Short param. Returns value or 0.

    Definition Classes
    Request
  66. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  67. def headerMap: HeaderMap

    A HeaderMap (i.e., HTTP headers) associated with this message.

    A HeaderMap (i.e., HTTP headers) associated with this message.

    Definition Classes
    ProxyMessage
    Note

    This structure isn't thread-safe. Any concurrent access should be synchronized externally.

  68. final def host(value: String): Proxy.this.type

    Set the Host header

    Set the Host header

    Definition Classes
    Message
    See also

    host_=(String) for Scala users

  69. def host: Option[String]

    Get Host header

    Get Host header

    Definition Classes
    Message
  70. def host_=(value: String): Unit

    Set Host header

    Set Host header

    Definition Classes
    Message
    See also

    host(String) for Java users

  71. final def isChunked: Boolean
    Definition Classes
    ProxyMessage
  72. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  73. final def isRequest: Boolean
    Definition Classes
    RequestMessage
  74. def isResponse: Boolean
    Definition Classes
    Message
  75. def isXmlHttpRequest: Boolean

    Check if X-Requested-With contains XMLHttpRequest, usually signalling a request from a JavaScript AJAX libraries.

    Check if X-Requested-With contains XMLHttpRequest, usually signalling a request from a JavaScript AJAX libraries. Some servers treat these requests specially. For example, an endpoint might render JSON or XML instead HTML if it's an XmlHttpRequest. (Tip: don't do this - it's gross.)

    Definition Classes
    Message
  76. final def keepAlive: Boolean
    Definition Classes
    Message
  77. final def keepAlive(keepAlive: Boolean): Proxy.this.type
    Definition Classes
    Message
  78. def lastModified: Option[String]

    Get Last-Modified header

    Get Last-Modified header

    Definition Classes
    Message
  79. def lastModified_=(value: Date): Unit

    Set Last-Modified header by Date

    Set Last-Modified header by Date

    Definition Classes
    Message
  80. def lastModified_=(value: String): Unit

    Set Last-Modified header

    Set Last-Modified header

    Definition Classes
    Message
  81. final def length: Int

    Get length of content.

    Get length of content.

    Definition Classes
    Message
  82. def location: Option[String]

    Get Location header

    Get Location header

    Definition Classes
    Message
  83. def location_=(value: String): Unit

    Set Location header

    Set Location header

    Definition Classes
    Message
  84. def mediaType: Option[String]

    Get media-type from Content-Type header

    Get media-type from Content-Type header

    Definition Classes
    Message
  85. def mediaType_=(value: String): Unit

    Set media-type in Content-Type header.

    Set media-type in Content-Type header. Charset and parameter values are preserved, though may not be appropriate for the new media type.

    Definition Classes
    Message
  86. final def method: Method

    Returns the HTTP method of this request.

    Returns the HTTP method of this request.

    Definition Classes
    ProxyRequest
  87. final def method(method: Method): Proxy.this.type

    Sets the HTTP method of this request to the given method.

    Sets the HTTP method of this request to the given method.

    Definition Classes
    Request
    See also

    method_=(Method) for Scala users.

  88. final def method_=(method: Method): Unit

    Sets the HTTP method of this request to the given method.

    Sets the HTTP method of this request to the given method.

    * @see method(Method) for Java users.

    Definition Classes
    ProxyRequest
  89. final def multipart: Option[Multipart]

    Returns an _optional_ Multipart instance, which maintains the multipart/form-data content of this non-chunked, POST request.

    Returns an _optional_ Multipart instance, which maintains the multipart/form-data content of this non-chunked, POST request. If this requests is either streaming or non-POST, this method returns None.

    Note: This method is a part of an experimental API for handling multipart HTTP data and it will likely be changed in future in order to support streaming requests.

    Definition Classes
    ProxyRequest
  90. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  91. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  92. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  93. def params: ParamMap

    Returns a ParamMap instance, which maintains query string and url-encoded params associated with this request.

    Returns a ParamMap instance, which maintains query string and url-encoded params associated with this request.

    Definition Classes
    ProxyRequest
  94. def path: String

    Path from URI.

    Path from URI.

    Definition Classes
    Request
    Annotations
    @BeanProperty()
  95. def reader: Reader

    A read-only handle to the internal stream of bytes, representing the message body.

    A read-only handle to the internal stream of bytes, representing the message body. See com.twitter.io.Reader for more information.

    Definition Classes
    ProxyMessage
  96. def referer: Option[String]

    Get Referer [sic] header

    Get Referer [sic] header

    Definition Classes
    Message
  97. def referer_=(value: String): Unit

    Set Referer [sic] header

    Set Referer [sic] header

    Definition Classes
    Message
  98. def remoteAddress: InetAddress

    Remote InetAddress

    Remote InetAddress

    Definition Classes
    Request
    Annotations
    @BeanProperty()
  99. def remoteHost: String

    Remote host - a dotted quad

    Remote host - a dotted quad

    Definition Classes
    Request
    Annotations
    @BeanProperty()
  100. def remotePort: Int

    Remote port

    Remote port

    Definition Classes
    Request
    Annotations
    @BeanProperty()
  101. def remoteSocketAddress: InetSocketAddress

    The InetSocketAddress of the client or a place-holder ephemeral address for requests that have yet to be dispatched.

    The InetSocketAddress of the client or a place-holder ephemeral address for requests that have yet to be dispatched.

    Definition Classes
    ProxyRequest
  102. def removeCookie(name: String): Unit

    Remove a cookie

    Remove a cookie

    Definition Classes
    Message
  103. lazy val response: Response

    Response associated with request.

    Response associated with request.

    Definition Classes
    ProxyRequest
  104. def retryAfter: Option[String]

    Get Retry-After header

    Get Retry-After header

    Definition Classes
    Message
  105. def retryAfter_=(value: Long): Unit

    Set Retry-After header by seconds

    Set Retry-After header by seconds

    Definition Classes
    Message
  106. def retryAfter_=(value: String): Unit

    Set Retry-After header

    Set Retry-After header

    Definition Classes
    Message
  107. def server: Option[String]

    Get Server header

    Get Server header

    Definition Classes
    Message
  108. def server_=(value: String): Unit

    Set Server header

    Set Server header

    Definition Classes
    Message
  109. final def setChunked(chunked: Boolean): Unit

    Manipulate the Message content mode.

    Manipulate the Message content mode.

    If chunked is true, any existing content will be discarded and further attempts to manipulate the synchronous content will result in an IllegalStateException.

    If chunked is false, the synchronous content methods will become available and the Reader/Writer of the message will be ignored by Finagle.

    Definition Classes
    ProxyMessage
  110. final def setContentString(value: String): Unit

    Set the content as a string.

    Set the content as a string.

    Definition Classes
    Message
  111. def setContentType(mediaType: String, charset: String = "utf-8"): Unit

    Set Content-Type header by media-type and charset

    Set Content-Type header by media-type and charset

    Definition Classes
    Message
  112. def setContentTypeJson(): Unit

    Set Content-Type header to application/json;charset=utf-8

    Set Content-Type header to application/json;charset=utf-8

    Definition Classes
    Message
  113. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  114. def toString(): String
    Definition Classes
    Request → AnyRef → Any
  115. def uri: String

    Returns the URI of this request.

    Returns the URI of this request.

    Definition Classes
    ProxyRequest
  116. final def uri(value: String): Proxy.this.type

    Set the URI of this request.

    Set the URI of this request.

    Definition Classes
    Request
    See also

    uri_=(String) for Scala users.

  117. final def uri_=(uri: String): Unit

    Set the URI of this request to the given uri.

    Set the URI of this request to the given uri.

    Definition Classes
    ProxyRequest
    See also

    uri(String) for Java users.

  118. def userAgent: Option[String]

    Get User-Agent header

    Get User-Agent header

    Definition Classes
    Message
  119. def userAgent_=(value: String): Unit

    Set User-Agent header

    Set User-Agent header

    Definition Classes
    Message
  120. final def version: Version

    Get the HTTP version

    Get the HTTP version

    Definition Classes
    ProxyMessage
  121. final def version(version: Version): Proxy.this.type

    Set the HTTP version

    Set the HTTP version

    * @see version_=(Version) for Scala users

    Definition Classes
    Message
  122. final def version_=(version: Version): Unit

    Set the HTTP version

    Set the HTTP version

    Definition Classes
    ProxyMessage
    See also

    version(Version) for Java users

  123. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  124. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  125. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  126. def withInputStream[T](f: (InputStream) ⇒ T): T

    Use content as InputStream.

    Use content as InputStream. The underlying channel buffer's reader index is advanced. (Scala interface. Java users can use getInputStream().)

    Definition Classes
    Message
  127. final def withOutputStream[T](f: (OutputStream) ⇒ T): T

    Append content via an OutputStream.

    Append content via an OutputStream.

    An IllegalStateException is thrown if this message is chunked.

    Definition Classes
    Message
    Annotations
    @throws( classOf[IllegalStateException] )
  128. final def withReader[T](f: (Reader) ⇒ T): T

    Use content as Reader.

    Use content as Reader. (Scala interface. Java users can use getReader().)

    Definition Classes
    Message
  129. final def withWriter[T](f: (Writer) ⇒ T): T

    Append content via a Writer.

    Append content via a Writer.

    An IllegalStateException is thrown if this message is chunked.

    Definition Classes
    Message
    Annotations
    @throws( classOf[IllegalStateException] )
  130. final def write(bytes: Array[Byte]): Unit

    Append bytes to content.

    Append bytes to content.

    This method makes a defensive copy of the provided byte array. This can be avoided by wrapping the byte array via Buf.ByteArray.Owned and using the write(Buf) method.

    An IllegalStateException is thrown if this message is chunked.

    Definition Classes
    Message
    Annotations
    @throws( classOf[IllegalStateException] )
  131. final def write(buf: Buf): Unit

    Append a Buf to content.

    Append a Buf to content.

    An IllegalStateException is thrown if this message is chunked.

    Definition Classes
    Message
    Annotations
    @throws( classOf[IllegalStateException] )
  132. final def write(string: String): Unit

    Append string to content.

    Append string to content.

    An IllegalStateException is thrown if this message is chunked.

    Definition Classes
    Message
    Annotations
    @throws( classOf[IllegalStateException] )
  133. def writer: Writer with Closable

    A write-only handle to the internal stream of bytes, representing the message body.

    A write-only handle to the internal stream of bytes, representing the message body. See com.twitter.io.Writer for more information.

    Definition Classes
    ProxyMessage
  134. def wwwAuthenticate: Option[String]

    Get WWW-Authenticate header

    Get WWW-Authenticate header

    Definition Classes
    Message
  135. def wwwAuthenticate_=(value: String): Unit

    Set WWW-Authenticate header

    Set WWW-Authenticate header

    Definition Classes
    Message
  136. def xForwardedFor: Option[String]

    Get X-Forwarded-For header

    Get X-Forwarded-For header

    Definition Classes
    Message
  137. def xForwardedFor_=(value: String): Unit

    Set X-Forwarded-For header

    Set X-Forwarded-For header

    Definition Classes
    Message

Deprecated Value Members

  1. def getResponse(): Response

    Get response associated with request.

    Get response associated with request.

    Definition Classes
    Request
    Annotations
    @deprecated
    Deprecated

    (Since version 2016-12-29) Use the Response constructor functions

Inherited from Request

Inherited from Message

Inherited from AnyRef

Inherited from Any

Ungrouped