|
Module HTTP/ClientThis module is undocumented. This is a list of its definitions. NO_FAILURE_HANDLER :: Throwable -> <Proc> () NO_RESPONSE_HANDLER :: Response -> <Proc> () acceptEncoding :: Builder -> [String] -> <Proc> Builder Sets the content encodings the request declares as acceptable, that is, its
acceptLanguage :: Builder -> [String] -> <Proc> Builder acceptMediaType :: Builder -> [MediaType] -> <Proc> Builder Sets the media types the request declares as acceptable, that is, its asyncInvoke :: Invocation -> (Response -> <Proc> ()) -> (Throwable -> <Proc> ()) -> <Proc> Future Response Sends the request without waiting for the response and returns a future for it. Exactly one of the two handlers is called when the exchange ends: the first with the response, whatever its status, or the second with the failure that prevented a response. The handlers run in a background thread, in an SCL context derived from the one that was current when the request was submitted. Anything the response owns, including the client, must be released by the handlers rather than by the caller, which returns first. build :: Builder -> String -> <Proc> Invocation Builds an invocation for an arbitrary HTTP method, named by the string, and without a request entity. buildClient :: ClientBuilder -> <Proc> Client Creates a client from the given configuration. Support for multipart
entities is registered into the client, so entities built with the
The result owns network resources and must be released with buildDelete :: Builder -> <Proc> Invocation Builds a DELETE invocation from the request built so far. buildGet :: Builder -> <Proc> Invocation Builds a GET invocation from the request built so far. buildPost :: Builder -> Entity -> <Proc> Invocation Builds a POST invocation that sends the given entity as the request body. buildPut :: Builder -> Entity -> <Proc> Invocation Builds a PUT invocation that sends the given entity as the request body. chunkedPost :: Client -> String -> File -> Integer -> <Proc,Exception> Response POSTs the contents of the file to the URL as
The chunking settings are set on the client itself, so they stay in effect for the requests made through that client afterwards. chunkedPostAuth :: Client -> String -> File -> Integer -> String -> <Proc,Exception> Response As chunkedPut :: Client -> String -> File -> Integer -> <Proc,Exception> Response As chunkedPutAuth :: Client -> String -> File -> Integer -> String -> <Proc,Exception> Response As clientBuilder :: <Proc> ClientBuilder A client configuration with the default settings. close :: Client -> <Proc> () Closes the client and releases the connections and threads it holds. A client that is not closed leaks them, so close it once the last response obtained through it has been read. entity :: a -> MediaType -> <Proc> Entity An entity that sends the given value as the given media type. The value is
converted to bytes by the writer the client has for that combination of
value type and media type; a formEntity :: Form -> <Proc> Entity An entity that sends the form as header :: Builder -> String -> String -> <Proc> Builder Adds a header with the given name and value to the request. onReadProgress :: WebTarget -> (Long -> <Proc> ()) -> <Proc> () Registers a callback that is called while a response entity is being read through the given target. The argument is the number of bytes read so far, counted from the beginning of the entity. onWriteProgress :: WebTarget -> (Long -> <Proc> ()) -> <Proc> () Registers a callback that is called while a request entity is being written through the given target. The argument is the number of bytes written so far, counted from the beginning of the entity. path :: WebTarget -> String -> <Proc> WebTarget Returns a new target whose URI is the given path appended to the URI of the given target. possibleContentLengthOf :: Response -> <Proc> Maybe Long The length of the response entity as announced by its possibleHeaderOf :: Response -> String -> <Proc> Maybe String The value of the named header, or property :: Client -> String -> a -> <Proc> Dynamic Sets a configuration property of the client, and returns the client itself. The property affects every request made through the client afterwards. readEntity :: VecComp a => Response -> <Proc,Exception> a Reads the entity of the response and converts it to the expected type, which
is determined by the context in which the result is used; Reading consumes the underlying stream, so this can normally be done only once per response; a second attempt fails. It also fails if the server sent no entity, or if no reader is registered for the combination of the response media type and the expected type. readEntity_ :: Response -> Class a -> <Proc,Exception> a request :: WebTarget -> <Proc> Builder Starts building a request against the target. statusCodeOf :: Response -> <Proc> Integer The HTTP status code of the response, for example 200 or 404. statusMessageOf :: Response -> <Proc> String The reason phrase that belongs to the status of the response, for example
syncInvoke :: Invocation -> <Proc,Exception> Response Sends the request and waits for the response. An unsuccessful HTTP status is not an error here: the response is returned
whatever its status, and the status is read with target :: Client -> String -> <Proc> WebTarget A target for the given URI, against which requests can then be built. trustAllClientBuilder :: <Proc> ClientBuilder A client configuration that accepts every server certificate and every host name without checking either. This gives up the protection TLS provides against a man-in-the-middle, so use it only against servers you control, such as a test server with a self-signed certificate. |