[ Index ] |
PHP Cross Reference of Phabricator |
[Source view] [Print] [Project Stats]
(no description)
File Size: | 984 lines (30 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Request:: (65 methods):
__construct()
ini()
resetIni()
d()
hasTimeout()
hasBeenInitialized()
hasBasicAuth()
hasDigestAuth()
timeout()
followRedirects()
doNotFollowRedirects()
send()
sendIt()
uri()
basicAuth()
authenticateWith()
authenticateWithBasic()
digestAuth()
authenticateWithDigest()
hasClientSideCert()
clientSideCert()
authenticateWithCert()
body()
mime()
sendsAndExpectsType()
sendsAndExpects()
method()
expects()
expectsType()
contentType()
sends()
sendsType()
strictSSL()
withoutStrictSSL()
withStrictSSL()
serializePayload()
neverSerializePayload()
smartSerializePayload()
alwaysSerializePayload()
addHeader()
addHeaders()
autoParse()
withoutAutoParsing()
withAutoParsing()
parseWith()
parseResponsesWith()
registerPayloadSerializer()
serializePayloadWith()
__call()
_initializeDefaults()
_setDefaults()
_error()
init()
_curlPrep()
buildUserAgent()
addOnCurlOption()
_serializePayload()
get()
getQuick()
post()
put()
patch()
delete()
head()
options()
__construct($attrs = null) X-Ref |
We made the constructor private to force the factory style. This was done to keep the syntax cleaner and better the support the idea of "default templates". Very basic and flexible as it is only intended for internal use. param: array $attrs hash of initial attribute values |
ini(Request $template) X-Ref |
Let's you configure default settings for this class from a template Request object. Simply construct a Request object as much as you want to and then pass it to this method. It will then lock in those settings from that template object. The most common of which may be default mime settings or strict ssl settings. Again some slight memory overhead incurred here but in the grand scheme of things as it typically only occurs once param: Request $template |
resetIni() X-Ref |
Reset the default template back to the library defaults. |
d($attr) X-Ref |
Get default for a value based on the template object param: string|null $attr Name of attribute (e.g. mime, headers) return: mixed default value |
hasTimeout() X-Ref |
return: bool does the request have a timeout? |
hasBeenInitialized() X-Ref |
return: bool has the internal curl request been initialized? |
hasBasicAuth() X-Ref |
return: bool Is this request setup for basic auth? |
hasDigestAuth() X-Ref |
return: bool Is this request setup for digest auth? |
timeout($timeout) X-Ref |
Specify a HTTP timeout param: |int $timeout seconds to timeout the HTTP call return: Request $this |
followRedirects($follow = true) X-Ref |
If the response is a 301 or 302 redirect, automatically send off another request to that location param: bool|int $follow follow or not to follow or maximal number of redirects return: Request $this |
doNotFollowRedirects() X-Ref |
return: Request $this |
send() X-Ref |
Actually send off the request, and parse the response return: string|associative array of parsed results |
sendIt() X-Ref |
No description |
uri($uri) X-Ref |
param: string $uri return: Request this |
basicAuth($username, $password) X-Ref |
User Basic Auth. Only use when over SSL/TSL/HTTPS. param: string $username param: string $password return: Request this |
authenticateWith($username, $password) X-Ref |
No description |
authenticateWithBasic($username, $password) X-Ref |
No description |
digestAuth($username, $password) X-Ref |
User Digest Auth. param: string $username param: string $password return: Request this |
authenticateWithDigest($username, $password) X-Ref |
No description |
hasClientSideCert() X-Ref |
return: is this request setup for client side cert? |
clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM') X-Ref |
Use Client Side Cert Authentication param: string $key file path to client key param: string $cert file path to client cert param: string $passphrase for client key param: string $encoding default PEM return: Response $this |
authenticateWithCert($cert, $key, $passphrase = null, $encoding = 'PEM') X-Ref |
No description |
body($payload, $mimeType = null) X-Ref |
Set the body of the request param: mixed $payload param: string $mimeType return: Request this |
mime($mime) X-Ref |
Helper function to set the Content type and Expected as same in one swoop param: string $mime mime type to use for content type and expected return type return: Request this |
sendsAndExpectsType($mime) X-Ref |
No description |
sendsAndExpects($mime) X-Ref |
No description |
method($method) X-Ref |
Set the method. Shouldn't be called often as the preferred syntax for instantiation is the method specific factory methods. param: string $method return: Request this |
expects($mime) X-Ref |
param: string $mime return: Request this |
expectsType($mime) X-Ref |
No description |
contentType($mime) X-Ref |
param: string $mime return: Request this |
sends($mime) X-Ref |
No description |
sendsType($mime) X-Ref |
No description |
strictSSL($strict) X-Ref |
Do we strictly enforce SSL verification? param: bool $strict return: Request this |
withoutStrictSSL() X-Ref |
No description |
withStrictSSL() X-Ref |
No description |
serializePayload($mode) X-Ref |
Determine how/if we use the built in serialization by setting the serialize_payload_method The default (SERIALIZE_PAYLOAD_SMART) is... - if payload is not a scalar (object/array) use the appropriate serialize method according to the Content-Type of this request. - if the payload IS a scalar (int, float, string, bool) than just return it as is. When this option is set SERIALIZE_PAYLOAD_ALWAYS, it will always use the appropriate serialize option regardless of whether payload is scalar or not When this option is set SERIALIZE_PAYLOAD_NEVER, it will never use any of the serialization methods. Really the only use for this is if you want the serialize methods to handle strings or not (e.g. Blah is not valid JSON, but "Blah" is). Forcing the serialization helps prevent that kind of error from happening. param: int $mode return: Request $this |
neverSerializePayload() X-Ref |
return: Request |
smartSerializePayload() X-Ref |
This method is the default behavior return: Request |
alwaysSerializePayload() X-Ref |
return: Request |
addHeader($header_name, $value) X-Ref |
Add an additional header to the request Can also use the cleaner syntax of $Request->withMyHeaderName($my_value); param: string $header_name param: string $value return: Request this |
addHeaders(array $headers) X-Ref |
Add group of headers all at once. Note: This is here just as a convenience in very specific cases. The preferred "readable" way would be to leverage the support for custom header methods. param: array $headers return: Response $this |
autoParse($auto_parse = true) X-Ref |
param: bool $auto_parse perform automatic "smart" return: Request |
withoutAutoParsing() X-Ref |
return: Request |
withAutoParsing() X-Ref |
return: Request |
parseWith(\Closure $callback) X-Ref |
Use a custom function to parse the response. param: \Closure $callback Takes the raw body of return: Request this |
parseResponsesWith(\Closure $callback) X-Ref |
param: \Closure $callback return: Request $this |
registerPayloadSerializer($mime, \Closure $callback) X-Ref |
Register a callback that will be used to serialize the payload for a particular mime type. When using "*" for the mime type, it will use that parser for all responses regardless of the mime type. If a custom '*' and 'application/json' exist, the custom 'application/json' would take precedence over the '*' callback. param: string $mime mime type we're registering param: Closure $callback takes one argument, $payload, return: Request $this |
serializePayloadWith(\Closure $callback) X-Ref |
param: Closure $callback return: Request $this |
__call($method, $args) X-Ref |
Magic method allows for neatly setting other headers in a similar syntax as the other setters. This method also allows for the sends* syntax. param: string $method "missing" method name called param: array $args in this case, there should only ever be 1 argument provided return: Request this |
_initializeDefaults() X-Ref |
This is the default template to use if no template has been provided. The template tells the class which default values to use. While there is a slight overhead for object creation once per execution (not once per Request instantiation), it promotes readability and flexibility within the class. |
_setDefaults() X-Ref |
Set the defaults on a newly instantiated object Doesn't copy variables prefixed with _ return: Request this |
_error($error) X-Ref |
No description |
init($method = null, $mime = null) X-Ref |
Factory style constructor works nicer for chaining. This should also really only be used internally. The Request::get, Request::post syntax is preferred as it is more readable. param: string $method Http Method param: string $mime Mime Type to Use return: Request |
_curlPrep() X-Ref |
Does the heavy lifting. Uses de facto HTTP library cURL to set up the HTTP request. Note: It does NOT actually send the request return: Request $this; |
buildUserAgent() X-Ref |
No description |
addOnCurlOption($curlopt, $curloptval) X-Ref |
Semi-reluctantly added this as a way to add in curl opts that are not otherwise accessible from the rest of the API. param: string $curlopt param: mixed $curloptval return: Request $this |
_serializePayload($payload) X-Ref |
Turn payload from structured data into a string based on the current Mime type. This uses the auto_serialize option to determine it's course of action. See serialize method for more. Renamed from _detectPayload to _serializePayload as of 2012-02-15. Added in support for custom payload serializers. The serialize_payload_method stuff still holds true though. param: mixed $payload return: string |
get($uri, $mime = null) X-Ref |
HTTP Method Get param: string $uri optional uri to use param: string $mime expected return: Request |
getQuick($uri, $mime = null) X-Ref |
Like Request:::get, except that it sends off the request as well returning a response param: string $uri optional uri to use param: string $mime expected return: Response |
post($uri, $payload = null, $mime = null) X-Ref |
HTTP Method Post param: string $uri optional uri to use param: string $payload data to send in body of request param: string $mime MIME to use for Content-Type return: Request |
put($uri, $payload = null, $mime = null) X-Ref |
HTTP Method Put param: string $uri optional uri to use param: string $payload data to send in body of request param: string $mime MIME to use for Content-Type return: Request |
patch($uri, $payload = null, $mime = null) X-Ref |
HTTP Method Patch param: string $uri optional uri to use param: string $payload data to send in body of request param: string $mime MIME to use for Content-Type return: Request |
delete($uri, $mime = null) X-Ref |
HTTP Method Delete param: string $uri optional uri to use return: Request |
head($uri) X-Ref |
HTTP Method Head param: string $uri optional uri to use return: Request |
options($uri) X-Ref |
HTTP Method Options param: string $uri optional uri to use return: Request |
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |