\triagens\ArangoDbHttpHelper

Helper methods for HTTP request/response handling


Summary

Methods
Properties
Constants
validateMethod()
buildRequest()
transfer()
createConnection()
parseHttpMessage()
parseHeaders()
No public properties found
METHOD_POST
METHOD_PUT
METHOD_DELETE
METHOD_GET
METHOD_HEAD
METHOD_PATCH
CHUNK_SIZE
EOL
PROTOCOL
MIME_BOUNDARY
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

METHOD_POST

METHOD_POST

HTTP POST string constant

METHOD_PUT

METHOD_PUT

HTTP PUT string constant

METHOD_DELETE

METHOD_DELETE

HTTP DELETE string constant

METHOD_GET

METHOD_GET

HTTP GET string constant

METHOD_HEAD

METHOD_HEAD

HTTP HEAD string constant

METHOD_PATCH

METHOD_PATCH

HTTP PATCH string constant

CHUNK_SIZE

CHUNK_SIZE

Chunk size (number of bytes processed in one batch)

EOL

EOL

End of line mark used in HTTP

PROTOCOL

PROTOCOL

HTTP protocol version used, hard-coded to version 1.1

MIME_BOUNDARY

MIME_BOUNDARY

HTTP protocol version used, hard-coded to version 1.1

Methods

validateMethod()

validateMethod(string $method) : boolean

Validate an HTTP request method name

Parameters

string $method
  • method name

Throws

\triagens\ArangoDb\ClientException

Returns

boolean —
  • always true, will throw if an invalid method name is supplied

buildRequest()

buildRequest(\triagens\ArangoDb\ConnectionOptions $options, string $method, string $url, string $body, array $customerHeader) : string

Create a request string (header and body)

Parameters

\triagens\ArangoDb\ConnectionOptions $options
  • connection options
string $method
  • HTTP method
string $url
  • HTTP URL
string $body
  • optional body to post
array $customerHeader
  • any arry containing header elements

Returns

string —
  • assembled HTTP request string

transfer()

transfer(resource $socket, string $request) : string

Execute an HTTP request on an opened socket

It is the caller's responsibility to close the socket

Parameters

resource $socket
  • connection socket (must be open)
string $request
  • complete HTTP request as a string

Throws

\triagens\ArangoDb\ClientException

Returns

string —
  • HTTP response string as provided by the server

createConnection()

createConnection(\triagens\ArangoDb\ConnectionOptions $options) : resource

Create a one-time HTTP connection by opening a socket to the server

It is the caller's responsibility to close the socket

Parameters

\triagens\ArangoDb\ConnectionOptions $options
  • connection options

Throws

\triagens\ArangoDb\ConnectException

Returns

resource —
  • socket with server connection, will throw when no connection can be established

parseHttpMessage()

parseHttpMessage(string $httpMessage) : array

Splits a http message into its header and body.

Parameters

string $httpMessage

The http message string.

Throws

\triagens\ArangoDb\ClientException

Returns

array

parseHeaders()

parseHeaders(string $headers) : array

Process a string of HTTP headers into an array of header => values.

Parameters

string $headers
  • the headers string

Returns

array