addHeaderLine() public method

@param string $header_line Text of full header line.
public addHeaderLine ( string $header_line )
$header_line string
Example #1
0
 /**
  *    Adds additional manual headers.
  *    @param SimpleHttpRequest $request    Outgoing request.
  *    @access private
  */
 protected function addAdditionalHeaders(&$request)
 {
     foreach ($this->additional_headers as $header) {
         $request->addHeaderLine($header);
     }
 }
Example #2
0
 /**
  *    Presents the appropriate headers for this
  *    location for basic authentication.
  *    @param SimpleHttpRequest $request  Request to modify.
  *    @param string $username            Username for realm.
  *    @param string $password            Password for realm.
  *    @access public
  */
 static function addBasicHeaders($request, $username, $password)
 {
     if ($username && $password) {
         $request->addHeaderLine('Authorization: Basic ' . base64_encode("{$username}:{$password}"));
     }
 }
Example #3
0
 public function testWritingAdditionalHeaders()
 {
     $socket = new MockSimpleSocket();
     $socket->expectAt(0, 'write', array("My: stuff\r\n"));
     $socket->expectAt(1, 'write', array("\r\n"));
     $socket->expectCallCount('write', 2);
     $route = new MockSimpleRoute();
     $route->setReturnReference('createConnection', $socket);
     $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
     $request->addHeaderLine('My: stuff');
     $request->fetch(15);
 }
Example #4
0
 /**
  *    Adds additional manual headers.
  *    @param SimpleHttpRequest $request    Outgoing request.
  *    @access private
  */
 function _addAdditionalHeaders($request)
 {
     foreach ($this->_additional_headers as $header) {
         $request->addHeaderLine($header);
     }
 }
Example #5
0
 /**
  *    Presents the appropriate headers for this
  *    location for basic authentication.
  *    @param SimpleHttpRequest $request  Request to modify.
  *    @param string $username            Username for realm.
  *    @param string $password            Password for realm.
  *    @access public
  *    @static
  */
 function addBasicHeaders(&$request, $username, $password) {
     if ($username && $password) {
         $request->addHeaderLine(
                 'Authorization: Basic ' . base64_encode("$username:$password"));
     }
 }
Example #6
0
 function testWritingAdditionalHeaders()
 {
     $request = new SimpleHttpRequest("http://a.valid.host/and/path");
     $request->addHeaderLine("My: stuff");
     $socket =& new MockSimpleSocket($this);
     $socket->setReturnValue("isError", false);
     $socket->expectArgumentsSequence(0, "write", array("GET /and/path HTTP/1.0\r\n"));
     $socket->expectArgumentsSequence(1, "write", array("Host: a.valid.host\r\n"));
     $socket->expectArgumentsSequence(2, "write", array("My: stuff\r\n"));
     $socket->expectArgumentsSequence(3, "write", array("Connection: close\r\n"));
     $socket->expectArgumentsSequence(4, "write", array("\r\n"));
     $socket->expectCallCount("write", 5);
     $request->fetch($socket);
     $socket->tally();
 }