com.uncarved.helpers.http

class Client

[source: com/uncarved/helpers/http/Client.scala]

abstract class Client
extends AnyRef
Interfacte for Http clients. If this interface is implemented, we can enrich it with various convenience functions
Direct Known Subclasses:
RichClient, BasicClient

Value Summary
var cache : ResponseCache
Cache used by the conditional get mechanism
protected abstract val client : org.apache.http.impl.client.DefaultHttpClient
derived classes must define how they create and configure the client
val connectionTimeout : Int
override this to set the connection timeout
val soTimeout : Int
override this to set the socket timeout
val userAgent : java.lang.String
override this to set the User-Agent header on outgoing requests.
Method Summary
protected def entityString (entity : scala.Option[org.apache.http.HttpEntity]) : java.lang.String
Translate an entity option into a string. Uses UTF-8 as a default encoding if the entity doesn't set a charset in its content-type header
abstract def fetch [T](req : Request)(thunk : (Response) => T) : T
Execute a request and run some code with the results.
abstract def fetchOk [T](req : Request)(thunk : (Response) => T) : T
Execute a request and run some code with the results if the response code is "OK" (200 to 204).
def shutdown : Unit
Shut the client connection manager down, freeing all connection resources
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
val userAgent : java.lang.String
override this to set the User-Agent header on outgoing requests.

val connectionTimeout : Int
override this to set the connection timeout

val soTimeout : Int
override this to set the socket timeout

var cache : ResponseCache
Cache used by the conditional get mechanism

protected abstract val client : org.apache.http.impl.client.DefaultHttpClient
derived classes must define how they create and configure the client

Method Details
abstract def fetch[T](req : Request)(thunk : (Response) => T) : T
Execute a request and run some code with the results.
Parameters
req - The http request (in the form of a Request)
thunk - A code snippet that takes a response code, the response and an entity option that will be None if the response didn't result in an entity

abstract def fetchOk[T](req : Request)(thunk : (Response) => T) : T
Execute a request and run some code with the results if the response code is "OK" (200 to 204).
Parameters
req - The http request (in the form of a Request)
thunk - A code snippet that takes a response code, the response and an entity option that will be None if the response didn't result in an entity

protected def entityString(entity : scala.Option[org.apache.http.HttpEntity]) : java.lang.String
Translate an entity option into a string. Uses UTF-8 as a default encoding if the entity doesn't set a charset in its content-type header

def shutdown : Unit
Shut the client connection manager down, freeing all connection resources