1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 10:03:27 +01:00

240 lines
6.8 KiB
PHP
Raw Normal View History

<?php
namespace Guzzle\Tests\Http;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Common\Exception\RuntimeException;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\RequestFactory;
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
use Guzzle\Http\Client;
/**
* The Server class is used to control a scripted webserver using node.js that
* will respond to HTTP requests with queued responses.
*
* Queued responses will be served to requests using a FIFO order. All requests
* received by the server are stored on the node.js server and can be retreived
* by calling {@see Server::getReceivedRequests()}.
*
* Mock responses that don't require data to be transmitted over HTTP a great
* for testing. Mock respones, however, cannot test the actual sending of an
* HTTP request using cURL. This test server allows the simulation of any
* number of HTTP request response transactions to test the actual sending of
* requests over the wire without having to leave an internal network.
*/
class Server
{
const DEFAULT_PORT = 8124;
const REQUEST_DELIMITER = "\n----[request]\n";
/**
* @var int Port that the server will listen on
*/
private $port;
/**
* @var bool Is the server running
*/
private $running = false;
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
/**
* @var Client
*/
private $client;
/**
* Create a new scripted server
*
* @param int $port (optional) Port to listen on (defaults to 8124)
*/
public function __construct($port = null)
{
$this->port = $port ?: self::DEFAULT_PORT;
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
$this->client = new Client($this->getUrl());
}
/**
* Destructor to safely shutdown the node.js server if it is still running
*
* @codeCoverageIgnore
*/
public function __destruct()
{
// Only shut the server down if the object knows it started the server
if ($this->running) {
try {
$this->stop();
} catch (\Exception $e) {
}
}
}
/**
* Flush the received requests from the server
*
* @return bool Returns TRUE on success or FALSE on failure
* @throws RuntimeException
*/
public function flush()
{
if (!$this->isRunning()) {
return false;
}
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
return $this->client->delete('guzzle-server/requests')
->send()->getStatusCode() == 200;
}
/**
* Queue an array of responses or a single response on the server.
*
* Any currently queued responses will be overwritten. Subsequent requests
* on the server will return queued responses in FIFO order.
*
2011-03-03 12:24:51 -06:00
* @param array|Response $responses A single or array of Responses to queue
*
* @return bool Returns TRUE on success or FALSE on failure
* @throws BadResponseException
*/
public function enqueue($responses)
{
$data = array();
foreach ((array) $responses as $response) {
// Create the response object from a string
if (is_string($response)) {
Breaking / Potentially breaking changes: 1. Adopting a marker interface for Guzzle exceptions. A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception. B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection 2. Using Header objects for Request and Response objects A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match. This object can be cast to a string or iterated like an array. You can pass true in the second argument to retrieve the header as a string. B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods. All retrievals are case-insensitive and return Header objects. 3. Changing the two headers added by the cache plugin to just one header with key and ttl. 4. Changing Guzzle\Http\Message\Response::factory() to fromMessage(). 5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null New Features / enhancements: 1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders() 2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories. 3. Better handling of ports and hosts in Guzzle\Http\Url Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
2012-04-21 00:23:07 -07:00
$response = Response::fromMessage($response);
} else if (!($response instanceof Response)) {
throw new BadResponseException(
'Responses must be strings or implement Response'
);
}
$data[] = array(
Breaking / Potentially breaking changes: 1. Adopting a marker interface for Guzzle exceptions. A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception. B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection 2. Using Header objects for Request and Response objects A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match. This object can be cast to a string or iterated like an array. You can pass true in the second argument to retrieve the header as a string. B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods. All retrievals are case-insensitive and return Header objects. 3. Changing the two headers added by the cache plugin to just one header with key and ttl. 4. Changing Guzzle\Http\Message\Response::factory() to fromMessage(). 5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null New Features / enhancements: 1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders() 2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories. 3. Better handling of ports and hosts in Guzzle\Http\Url Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
2012-04-21 00:23:07 -07:00
'statusCode' => $response->getStatusCode(),
'reasonPhrase' => $response->getReasonPhrase(),
Breaking / Potentially breaking changes: 1. Adopting a marker interface for Guzzle exceptions. A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception. B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection 2. Using Header objects for Request and Response objects A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match. This object can be cast to a string or iterated like an array. You can pass true in the second argument to retrieve the header as a string. B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods. All retrievals are case-insensitive and return Header objects. 3. Changing the two headers added by the cache plugin to just one header with key and ttl. 4. Changing Guzzle\Http\Message\Response::factory() to fromMessage(). 5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null New Features / enhancements: 1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders() 2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories. 3. Better handling of ports and hosts in Guzzle\Http\Url Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
2012-04-21 00:23:07 -07:00
'headers' => $response->getHeaders()->getAll(),
'body' => $response->getBody(true)
);
}
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
$request = $this->client->put('guzzle-server/responses', null, json_encode($data));
$response = $request->send();
return $response->getStatusCode() == 200;
}
/**
* Check if the server is running
*
* @return bool
*/
public function isRunning()
{
if ($this->running) {
return true;
} else {
$fp = @fsockopen('127.0.0.1', $this->port, $errno, $errstr, 1);
if (!$fp) {
return false;
} else {
fclose($fp);
return true;
}
}
}
/**
* Get the URL to the server
*
* @return string
*/
public function getUrl()
{
return 'http://127.0.0.1:' . $this->getPort() . '/';
}
/**
* Get the port that the server is listening on
*
* @return int
*/
public function getPort()
{
return $this->port;
}
/**
* Get all of the received requests
*
* @param bool $hydrate (optional) Set to TRUE to turn the messages into
* actual {@see RequestInterface} objects. If $hydrate is FALSE,
* requests will be returned as strings.
*
* @return array
* @throws RuntimeException
*/
public function getReceivedRequests($hydrate = false)
{
$data = array();
if ($this->isRunning()) {
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
$response = $this->client->get('guzzle-server/requests')->send();
$data = array_filter(explode(self::REQUEST_DELIMITER, $response->getBody(true)));
if ($hydrate) {
$data = array_map(function($message) {
return RequestFactory::getInstance()->fromMessage($message);
}, $data);
}
}
return $data;
}
/**
* Start running the node.js server in the background
*/
public function start()
{
if (!$this->isRunning()) {
exec('node ' . __DIR__ . \DIRECTORY_SEPARATOR . 'server.js ' . $this->port . ' >> /tmp/server.log 2>&1 &');
// Shut the server down when the script exits unexpectedly
register_shutdown_function(array($this, 'stop'));
// Wait at most 5 seconds for the server the setup before proceeding
$start = time();
while (!$this->isRunning() && time() - $start < 5);
// @codeCoverageIgnoreStart
if (!$this->isRunning()) {
throw new RuntimeException(
'Unable to contact server.js. Have you installed node.js '
. 'v0.5.0+? The node.js executable, node, must also be in '
. 'your path.'
);
}
// @codeCoverageIgnoreEnd
}
$this->running = true;
}
/**
* Stop running the node.js server
*
* @return bool Returns TRUE on success or FALSE on failure
* @throws RuntimeException
*/
public function stop()
{
if (!$this->isRunning()) {
return false;
}
$this->running = false;
Guzzle 2.0 Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
2012-01-14 13:57:05 -06:00
return $this->client->delete('guzzle-server')->send()
->getStatusCode() == 200;
}
Breaking / Potentially breaking changes: 1. Adopting a marker interface for Guzzle exceptions. A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception. B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection 2. Using Header objects for Request and Response objects A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match. This object can be cast to a string or iterated like an array. You can pass true in the second argument to retrieve the header as a string. B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods. All retrievals are case-insensitive and return Header objects. 3. Changing the two headers added by the cache plugin to just one header with key and ttl. 4. Changing Guzzle\Http\Message\Response::factory() to fromMessage(). 5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null New Features / enhancements: 1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders() 2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories. 3. Better handling of ports and hosts in Guzzle\Http\Url Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
2012-04-21 00:23:07 -07:00
}