Skip to content

class Response

David Zurborg edited this page Aug 1, 2021 · 1 revision

src/Curl/ObjCurl/Response.php


Response

Package

Application

Overview

Public Properties

No public properties found

Constants

No constants found

Public Methods

__toString() | complain() | contentType() | cookie() | cookies() | decode() | decodeJSON() | decodeXML() | header() | headers() | id() | info() | infos() | is() | mimeParams() | mimeSubType() | mimeSuffix() | mimeTree() | mimeType() | payload() | raise() | status() | times() | url() |

Methods

__toString()

Returns HTTP response message

public __toString() : string

complain()

Log result depending on status code

public complain(\Psr\Log\LoggerInterface $logger, int $min_level = 3, array $context = []) : void

contentType()

Condensed MIME content type

public contentType(?string $type = null, ?string $subtype = null) : string

cookie()

Get a cookie

Returns null when cookie not found Returns string when cookie is found and $verbose is false Returns array when cookie is found and $verbose is true

public cookie(string $name, bool $verbose = false) : null|string|array

cookies()

Get all cookies

public cookies() : array

decode()

Decode payload (generic method with auto-detection)

Currently only JSON is supported.

public decode(?string $default_type = null) : mixed

decodeJSON()

Decode JSON payload

public decodeJSON(bool $assoc = false) : mixed

decodeXML()

Decode XML payload

public decodeXML(int $options) : \DOMDocument

header()

HTTP response header

public header(string $key) : string|array

headers()

HTTP response headers

public headers(string $key) : array

id()

Unique ID of request

public id() : string

info()

cURL getinfo

public info(string $key, mixed $default = null) : mixed

infos()

cURL getinfo

public infos() : array

is()

Checks whether a HTTP status code matches

$response->is(200); // matches only code 200 $response->is(30); // matches 30x (300..309) $response->is(4); // matches 4xx (400..499)

* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `is(int  $code) : bool`


#### mimeParams()

MIME parameters

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `mimeParams(?string  $default = null) : string`


#### mimeSubType()

MIME subtype

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `mimeSubType(?string  $default = null) : string`


#### mimeSuffix()

MIME suffix

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `mimeSuffix(?string  $default = null) : string`


#### mimeTree()

MIME subtree tree

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `mimeTree(?string  $default = null) : string`


#### mimeType()

Top-level MIME type

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `mimeType(?string  $default = null) : string`


#### payload()

Raw response body

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `payload() : string`


#### raise()

Throws this response as an runtime exception

> 
* Inherited from [\Curl\ObjCurl\Response](class-Response)

`public` `raise(string  $reason, int  $code) : mixed`


#### status()

HTTP status code

> ```php
$response->status(1) === 2; // status code is 2xx

public status(int $digits = 3) : int

times()

Return performance data

public times() : float[]

url()

Return request URI

public url(?string $part = null) : mixed


\ » Classes » Response