Chapter 1. User Guide Guzzle, Release // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length'); 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'contents' => 'hello', 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); Cookies Guzzle can maintain a cookie session for you if instructed using
retrieve headers from the response: // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length')[0]; 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); Cookies Guzzle can maintain a cookie session for you
retrieve headers from the response: // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length')[0]; 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); Cookies Guzzle can maintain a cookie session for you
retrieve headers from the response: // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length')[0]; 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'contents' => 'hello', 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); 1.2.5 Cookies Guzzle can maintain a cookie session for you if instructed
retrieve headers from the response: // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length'); 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); Cookies Guzzle can maintain a cookie session for you
Chapter 1. User Guide Guzzle, Release // Check if a header exists. if ($response->hasHeader('Content-Length')) { echo "It exists"; } // Get a header from the response. echo $response->getHeader('Content-Length')[0]; 'http://httpbin.org/post', ['body' => $body]); An easy way to upload JSON data and set the appropriate header is using the json request option: $r = $client->request('PUT', 'http://httpbin.org/put', [ 'json' 'contents' => 'hello', 'filename' => 'filename.txt', 'headers' => [ 'X-Foo' => 'this is an extra header to include' ] ] ] ]); 1.2.5 Cookies Guzzle can maintain a cookie session for you if instructed