/**
  * Sign HTTP request
  *
  * @param  peer.http.HttpRequest $request
  */
 public function sign(HttpRequest $request)
 {
     $request->setHeader('Authorization', $this->getValueRepresentation());
 }
Exemplo n.º 2
0
 public function with_duplicate_header()
 {
     $r = new HttpRequest(new URL('http://example.com/'));
     $r->setHeader('X-Binford', 6100);
     $r->setHeader('X-Binford', 61000);
     $this->assertEquals("GET / HTTP/1.1\r\nConnection: close\r\nHost: example.com\r\nX-Binford: 61000\r\n\r\n", $r->getRequestString());
 }
 /**
  * Sign the given request; ie. add an Authorization: Digest header
  * and increase the internal nonce counter.
  *
  * @param  peer.http.HttpRequest $request
  */
 public function sign(HttpRequest $request)
 {
     $url = $request->target;
     $params = [];
     if (is_array($request->parameters)) {
         $params = array_merge($params, $request->parameters);
     }
     if ($request->getUrl()->hasParams()) {
         $params = array_merge($params, $request->getUrl()->getParams());
     }
     if (sizeof($params)) {
         $url .= '?';
         foreach ($params as $k => $v) {
             $url .= $k . '=' . $v . '&';
         }
         $url = substr($url, 0, -1);
     }
     $request->setHeader('Authorization', $this->getValueRepresentation($request->method, $url));
     // Increase internal counter
     $this->counter++;
 }