当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpResponse::getHeaderString方法代码示例

本文整理汇总了PHP中HttpResponse::getHeaderString方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::getHeaderString方法的具体用法?PHP HttpResponse::getHeaderString怎么用?PHP HttpResponse::getHeaderString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpResponse的用法示例。


在下文中一共展示了HttpResponse::getHeaderString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAddManyCookiesToResponseObjectAndGetHeaderString

 /**
  * Test add many cookie and get correct header string
  */
 public function testAddManyCookiesToResponseObjectAndGetHeaderString()
 {
     // added date time
     $dateTime = new \DateTime('2014-07-02 01:02:03 GMT');
     // iterate and check values
     for ($i = 1; $i <= 5; $i++) {
         $this->response->addCookie(new HttpCookie("testCookieName00{$i}", md5($i), $dateTime, null, "testdomain00{$i}.local", "/path{$i}{$i}{$i}", $i === 3, $i !== 1));
     }
     // get header string
     $headerString = $this->response->getHeaderString();
     $this->assertSame($headerString, "Set-Cookie: testCookieName001=c4ca4238a0b923820dcc509a6f75849b; Expires=Wed, 02-Jul-2014 01:02:03 GMT; Domain=testdomain001.local; Path=/path111\r\n" . "Set-Cookie: testCookieName002=c81e728d9d4c2f636f067f89cc14862c; Expires=Wed, 02-Jul-2014 01:02:03 GMT; Domain=testdomain002.local; Path=/path222; HttpOnly\r\n" . "Set-Cookie: testCookieName003=eccbc87e4b5ce2fe28308fd9f2a7baf3; Expires=Wed, 02-Jul-2014 01:02:03 GMT; Domain=testdomain003.local; Path=/path333; Secure; HttpOnly\r\n" . "Set-Cookie: testCookieName004=a87ff679a2f3e71d9181a67b7542122c; Expires=Wed, 02-Jul-2014 01:02:03 GMT; Domain=testdomain004.local; Path=/path444; HttpOnly\r\n" . "Set-Cookie: testCookieName005=e4da3b7fbbce2345d7772b0674a318d5; Expires=Wed, 02-Jul-2014 01:02:03 GMT; Domain=testdomain005.local; Path=/path555; HttpOnly\r\n\r\n");
 }
开发者ID:techdivision,项目名称:http,代码行数:15,代码来源:ResponseTest.php

示例2: send

 /**
  * Sends a request
  *
  * @param   peer.http.HttpRequest request
  * @param   int timeout default 60
  * @param   float connecttimeout default 2.0
  * @return  peer.http.HttpResponse response object
  */
 public function send(HttpRequest $request, $timeout = 60, $connecttimeout = 2.0)
 {
     // Use proxy socket and Modify target if a proxy is to be used for this request,
     // a proxy wants "GET http://example.com/ HTTP/X.X"
     if ($this->proxy && !$this->proxy->isExcluded($url = $request->getUrl())) {
         $request->setTarget(sprintf('%s://%s%s%s', $url->getScheme(), $url->getHost(), $url->getPort() ? ':' . $url->getPort() : '', $url->getPath('/')));
         $s = $this->proxySocket;
     } else {
         $s = $this->socket;
     }
     // Socket still open from last request. This is the case when unread
     // data is left on the socket (by not reading the body, e.g.), so do
     // it the quick & dirty way: Close and reopen!
     $s->isConnected() && $s->close();
     $s->setTimeout($timeout);
     $s->connect($connecttimeout);
     $s->write($request->getRequestString());
     $this->cat && $this->cat->info('>>>', $request->getHeaderString());
     $response = new HttpResponse(new SocketInputStream($s));
     $this->cat && $this->cat->info('<<<', $response->getHeaderString());
     return $response;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:30,代码来源:SocketHttpTransport.class.php

示例3: send

 /**
  * Sends a request
  *
  * @param   peer.http.HttpRequest $request
  * @param   int $timeout default 60
  * @param   float $connecttimeout default 2.0
  * @return  peer.http.HttpResponse response object
  */
 public function send(HttpRequest $request, $timeout = 60, $connecttimeout = 2.0)
 {
     $curl = curl_copy_handle($this->handle);
     curl_setopt($curl, CURLOPT_URL, $request->url->getCanonicalURL());
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestString());
     curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
     if ($this->proxy && !$this->proxy->excludes()->contains($request->getUrl())) {
         curl_setopt($curl, CURLOPT_PROXY, $this->proxy->host());
         curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxy->port());
         $read = function ($transfer) {
             if (preg_match('#^HTTP/[0-9]\\.[0-9] [0-9]{3} .+\\r\\n\\r\\n#', $transfer, $matches)) {
                 // Strip "HTTP/x.x 200 Connection established" which is followed by
                 // the real HTTP message: headers and body
                 return substr($transfer, strlen($matches[0]));
             } else {
                 return $transfer;
             }
         };
     } else {
         $read = function ($transfer) {
             return $transfer;
         };
     }
     $return = curl_exec($curl);
     if (false === $return) {
         $errno = curl_errno($curl);
         $error = curl_error($curl);
         curl_close($curl);
         throw new \io\IOException(sprintf('%d: %s', $errno, $error));
     }
     // ensure handle is closed
     curl_close($curl);
     $this->cat && $this->cat->info('>>>', $request->getHeaderString());
     $response = new HttpResponse(new MemoryInputStream($read($return)), false);
     $this->cat && $this->cat->info('<<<', $response->getHeaderString());
     return $response;
 }
开发者ID:xp-framework,项目名称:http,代码行数:45,代码来源:CurlHttpTransport.class.php

示例4: send

 /**
  * Sends a request
  *
  * @param   peer.http.HttpRequest request
  * @param   int timeout default 60
  * @param   float connecttimeout default 2.0
  * @return  peer.http.HttpResponse response object
  */
 public function send(HttpRequest $request, $timeout = 60, $connecttimeout = 2.0)
 {
     $curl = curl_copy_handle($this->handle);
     curl_setopt($curl, CURLOPT_URL, $request->url->getCanonicalURL());
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestString());
     curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
     if ($this->proxy && !$this->proxy->isExcluded($request->getUrl())) {
         curl_setopt($curl, CURLOPT_PROXY, $this->proxy->host);
         curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxy->port);
     }
     $response = curl_exec($curl);
     if (FALSE === $response) {
         $errno = curl_errno($curl);
         $error = curl_error($curl);
         curl_close($curl);
         throw new IOException(sprintf('%d: %s', $errno, $error));
     }
     // ensure handle is closed
     curl_close($curl);
     $this->cat && $this->cat->info('>>>', $request->getHeaderString());
     $response = new HttpResponse(new MemoryInputStream($response));
     $this->cat && $this->cat->info('<<<', $response->getHeaderString());
     return $response;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:32,代码来源:CurlHttpTransport.class.php

示例5: send

 /**
  * Sends a request
  *
  * @param   peer.http.HttpRequest request
  * @param   int timeout default 60
  * @param   float connecttimeout default 2.0
  * @return  peer.http.HttpResponse response object
  */
 public function send(HttpRequest $request, $timeout = 60, $connecttimeout = 2.0)
 {
     // Use proxy socket and Modify target if a proxy is to be used for this request,
     // a proxy wants "GET http://example.com/ HTTP/X.X" for (and "CONNECT" for HTTPs).
     if ($this->proxy && !$this->proxy->excludes()->contains($url = $request->getUrl())) {
         $s = $this->connect($this->proxySocket, $timeout, $connecttimeout);
         $this->proxy($s, $request, $url);
     } else {
         $s = $this->connect($this->socket, $timeout, $connecttimeout);
     }
     $this->cat && $this->cat->info('>>>', $request->getHeaderString());
     $s->write($request->getRequestString());
     $response = new HttpResponse(new SocketInputStream($s));
     $this->cat && $this->cat->info('<<<', $response->getHeaderString());
     return $response;
 }
开发者ID:xp-framework,项目名称:http,代码行数:24,代码来源:SocketHttpTransport.class.php


注:本文中的HttpResponse::getHeaderString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。