本文整理汇总了PHP中Buzz\Message\Response类的典型用法代码示例。如果您正苦于以下问题:PHP Response类的具体用法?PHP Response怎么用?PHP Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: createResponse
protected function createResponse($content = '')
{
$response = new Buzz\Message\Response();
$response->addHeader('1.0 200 OK');
$response->setContent($content);
return $response;
}
开发者ID:pampy,项目名称:PiwikClient,代码行数:7,代码来源:HttpConnectionTest.php
示例2: createResponse
private function createResponse($content, $statusCode = 200)
{
$response = new Response();
$response->setContent($content);
$response->setHeaders(array('HTTP/1.1 ' . $statusCode . ' REASON'));
return $response;
}
开发者ID:wjzijderveld,项目名称:youless-client,代码行数:7,代码来源:ClientSpec.php
示例3: testAddHeadersResetsStatusLine
public function testAddHeadersResetsStatusLine()
{
$response = new Response();
$this->assertNull($response->getStatusCode());
$response->addHeaders(array('1.0 200 OK'));
$this->assertEquals(200, $response->getStatusCode());
}
开发者ID:kingsj,项目名称:core,代码行数:7,代码来源:ResponseTest.php
示例4: __construct
public function __construct(TransportResponse $response)
{
if (!$response->isSuccessful()) {
throw new TransportException($response);
}
$this->response = $response;
}
开发者ID:markey-magic,项目名称:tractionphp,代码行数:7,代码来源:Response.php
示例5: verifyResult
/**
* Verifies the last request.
* If the last request was not successful, it will be throw an exception.
*
* @param \Buzz\Message\Response $response The response object from the last reques
* @param string $url The url which was requested
* @return \Buzz\Message\Response
* @throws \Exception
*/
protected function verifyResult(\Buzz\Message\Response $response, $url)
{
if ($response->getStatusCode() !== 200) {
throw new \Exception('Request to "' . $url . '" failed', 1364061673);
}
return $response;
}
开发者ID:sschuberth,项目名称:Gerrie,代码行数:16,代码来源:HTTPDataService.php
示例6: parse
/**
* @param Response $curlResponse
*
* @throws HttpStatusParserException
*/
public function parse(Response $curlResponse)
{
$statusCode = $curlResponse->getStatusCode();
if ($this->shouldThrowException($statusCode)) {
throw new HttpStatusParserException($curlResponse->getContent(), $statusCode);
}
}
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:12,代码来源:HttpStatusParser.php
示例7: rev
public function rev(Response $response)
{
if ($response->isSuccessful()) {
return $this->decode($response->getHeader('Etag'));
}
throw new RugException('not_found', 'The specified document or revision cannot be found or has been deleted');
}
开发者ID:o100ja,项目名称:rug,代码行数:7,代码来源:AbstractDocumentParser.php
示例8: handleResponseAuthHeader
/**
* @param \Buzz\Message\Response $response
*/
private function handleResponseAuthHeader(\Buzz\Message\Response $response)
{
$token = $response->getHeader('Update-Client-Auth');
if ($token) {
$this->client->setAuthToken($token);
$this->setTokenToCache($token);
}
}
开发者ID:rgies,项目名称:dsp,代码行数:11,代码来源:ClientAuthManagerWrapper.php
示例9: send
/**
* @see Client\ClientInterface
*/
public function send(Message\Request $request, Message\Response $response)
{
if (!($queued = $this->receiveFromQueue())) {
throw new \LogicException('There are no queued responses.');
}
$response->setHeaders($queued->getHeaders());
$response->setContent($queued->getContent());
}
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:11,代码来源:AbstractQueue.php
示例10: it_can_search_with__query
public function it_can_search_with__query(Browser $client, Response $response)
{
$response->getContent()->shouldBeCalled();
$client->get(sprintf('%s/search?%s', 'http://endpoint', http_build_query(['q' => 'pilkington avenue, birmingham', 'format' => 'json'])), ['User-Agent' => 'Nomatim PHP Library (https://github.com/nixilla/nominatim-consumer); email: not set'])->shouldBeCalled()->willReturn($response);
$query = new Query();
$query->setQuery('pilkington avenue, birmingham');
$this->search($query)->shouldReturnAnInstanceOf('Nominatim\\Result\\Collection');
}
开发者ID:nixilla,项目名称:nominatim-consumer,代码行数:8,代码来源:ConsumerSpec.php
示例11: testGetDomReturnsADomDocument
public function testGetDomReturnsADomDocument()
{
$response = new Message\Response();
$response->setContent('<html><head></head><body></body></html>');
$this->browser->getClient()->sendToQueue($response);
$this->browser->get('http://www.google.com');
$this->assertTrue($this->browser->getDom() instanceof \DOMDocument);
}
开发者ID:philip,项目名称:Buzz,代码行数:8,代码来源:BrowserTest.php
示例12: assertHttpResponseHasHeader
protected function assertHttpResponseHasHeader(HttpResponse $response, $header, $expectedValue = null)
{
$headerValue = $response->getHeader($header);
self::assertNotNull($headerValue, "Failed asserting that response has a {$header} header");
if ($expectedValue !== null) {
self::assertEquals($expectedValue, $headerValue);
}
}
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:TestCase.php
示例13: _parse
public function _parse(Response $response, $mime = null)
{
$data = $this->decode($response->getContent(), $mime);
if (isset($data->error)) {
throw new RugException($data->error, $this->_error($data));
}
return $data;
}
开发者ID:o100ja,项目名称:rug,代码行数:8,代码来源:AbstractParser.php
示例14: processSetCookieHeaders
/**
* Processes Set-Cookie headers from a request/response pair.
*
* @param Message\Request $request A request object
* @param Message\Response $response A response object
*/
public function processSetCookieHeaders(Message\Request $request, Message\Response $response)
{
foreach ($response->getHeader('Set-Cookie', false) as $header) {
$cookie = new Cookie();
$cookie->fromSetCookieHeader($header, parse_url($request->getHost(), PHP_URL_HOST));
$this->addCookie($cookie);
}
}
开发者ID:philip,项目名称:Buzz,代码行数:14,代码来源:Jar.php
示例15: processResponse
/**
* @param Response $response
*
* @return string
*/
private function processResponse(Response $response)
{
$matches = [];
preg_match('/<input.*value="(.*)"/U', $response->getContent(), $matches);
if (!isset($matches[1])) {
throw new \RuntimeException('Screenshot upload failed');
}
return $matches[1];
}
开发者ID:stof,项目名称:behat-screenshot-image-driver-uploadpie,代码行数:14,代码来源:UploadPieApi.php
示例16: it_translates_a_text
/**
* @test
*/
public function it_translates_a_text()
{
$response = new Response();
$response->setContent('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">dit is een test</string>');
$this->browser->expects($this->once())->method('get')->with('http://api.microsofttranslator.com/v2/Http.svc/Translate?from=en&to=nl&text=this+is+a+test')->willReturn($response);
$translation = $this->translator->translate('en', 'nl', 'this is a test');
$expectedTranslation = 'dit is een test';
$this->assertEquals($expectedTranslation, $translation);
}
开发者ID:dhensen,项目名称:translator,代码行数:12,代码来源:BingTranslatorTest.php
示例17: getSender
/**
* @return SenderInterface
*/
private function getSender()
{
$client = $this->getMockBuilder('\\Team3\\PayU\\Communication\\Sender\\SenderInterface')->getMock();
$client->expects($this->any())->method('send')->willReturnCallback(function () {
$response = new Response();
$response->setContent(self::RESPONSE_CONTENT);
return $response;
});
return $client;
}
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:13,代码来源:ClientTest.php
示例18: __construct
/**
* @param string|null $message
*/
public function __construct(RequestInterface $request, Response $response, $message = null)
{
$this->request = $request;
$this->response = $response;
if ($message === null) {
$curlError = $response->getHeader('X-Curl-Error-Result');
$message = sprintf('HTTP %s request to "%s%s" failed: %d - "%s".', $request->getMethod(), $request->getHost(), $request->getResource(), $curlError ?: $response->getStatusCode(), $curlError ? curl_strerror($curlError) : $response->getReasonPhrase());
}
parent::__construct($message);
}
开发者ID:vaniocz,项目名称:VanioBuzzBundle,代码行数:13,代码来源:RequestFailedException.php
示例19: testGetBearerHeaderInvalidTokenTypeException
public function testGetBearerHeaderInvalidTokenTypeException()
{
$twitter = $this->getMockBuilder('Endroid\\Twitter\\Twitter')->setConstructorArgs(array('foo', 'bar'))->setMethods(array('getBasicHeader', 'call'))->getMock();
$twitter->expects($this->any())->method('getBasicHeader')->willReturn(self::EXPECTED_BASIC_HEADER);
$response = new Response();
$response->setContent(json_encode(array('token_type' => 'something_wrong', 'access_token' => 'cc4f26cc4a3f61a84436014b2166e431')));
$twitter->expects($this->any())->method('call')->with('POST', Twitter::BASE_URL . Twitter::TOKEN_URL)->willReturn($response);
$this->setExpectedException('Endroid\\Twitter\\Exception\\InvalidTokenTypeException');
Util::invokeMethod($twitter, 'getBearerHeader');
}
开发者ID:endroid,项目名称:twitter,代码行数:10,代码来源:TwitterTest.php
示例20: handleException
/**
* Lets us know if something went wrong
*
* @param Response $response
* @throws \Twitter\Exception\TwitterApiException
* @throws \Exception
*/
protected function handleException(Response $response)
{
$json_string = $response->getContent();
$output = json_decode($json_string, true);
if (count($output['errors'])) {
throw new TwitterApiException($output['errors'][0]['message'], $output['errors'][0]['code']);
} else {
throw new \Exception(sprintf('Unknown error: %s', $json_string));
}
}
开发者ID:nixilla,项目名称:twitter-api-consumer,代码行数:17,代码来源:Consumer.php
注:本文中的Buzz\Message\Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论