src/Net/HTTP/Request/Sender.php
public function send()
	{
		if( $this->method === 'POST' )
			$this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) );
		if( !$this->headers->getFieldsByName( 'connection' ) )
			$this->addHeaderPair( 'Connection', 'close' );

		$result	= "";
		$fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 );
		if( !$fp )
			throw new RuntimeException( $errstr.' ('.$errno.')' );

		$uri	= $this->uri/*.( $this->port ? ':'.$this->port : "" )*/;
		$lines	= array(
			$this->method." ".$uri." HTTP/".$this->version,
			$this->headers->render(),
		);
		if( $this->method === 'POST' )
			$lines[]	= $this->data;
		$lines	= join( "\r\n", $lines );
		fwrite( $fp, $lines );																		//  send Request
		while( !feof( $fp ) )																		//  receive Response
			$result .= fgets( $fp, 1024 );															//  collect Response chunks
		fclose( $fp );																				//  close Connection
		$response	= Net_HTTP_Response_Parser::fromString( $result );
		if( count( $response->getHeader( 'Location' ) ) ){
			$location	= array_shift( $response->getHeader( 'Location' ) );
			$this->host	= parse_url( $location->getValue(), PHP_URL_HOST );
			$this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) );
			$this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) );
			return $this->send();
		}
		return $response;
	}
public function send()
	{
		if( $this->method === 'POST' )
			$this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) );
		if( !$this->headers->getFieldsByName( 'connection' ) )
			$this->addHeaderPair( 'Connection', 'close' );

		$result	= "";
		$fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 );
		if( !$fp )
			throw new RuntimeException( $errstr.' ('.$errno.')' );

		$uri	= $this->uri/*.( $this->port ? ':'.$this->port : "" )*/;
		$lines	= array(
			$this->method." ".$uri." HTTP/".$this->version,
			$this->headers->render(),
		);
		if( $this->method === 'POST' )
			$lines[]	= $this->data;
		$lines	= join( "\r\n", $lines );
		fwrite( $fp, $lines );																		//  send Request
		while( !feof( $fp ) )																		//  receive Response
			$result .= fgets( $fp, 1024 );															//  collect Response chunks
		fclose( $fp );																				//  close Connection
		$response	= Net_HTTP_Response_Parser::fromString( $result );
		if( count( $response->getHeader( 'Location' ) ) ){
			$location	= array_shift( $response->getHeader( 'Location' ) );
			$this->host	= parse_url( $location->getValue(), PHP_URL_HOST );
			$this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) );
			$this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) );
			return $this->send();
		}
		return $response;
	}
public function send ( ) { if ( $ this -> method === 'POST' ) $ this -> addHeaderPair ( 'Content-Length' , mb_strlen ( $ this -> data ) ) ; if ( ! $ this -> headers -> getFieldsByName ( 'connection' ) ) $ this -> addHeaderPair ( 'Connection' , 'close' ) ; $ result = "" ; $ fp = fsockopen ( $ this -> host , $ this -> port , $ errno , $ errstr , 2 ) ; if ( ! $ fp ) throw new RuntimeException ( $ errstr . ' (' . $ errno . ')' ) ; $ uri = $ this -> uri /*.( $this->port ? ':'.$this->port : "" )*/ ; $ lines = array ( $ this -> method . " " . $ uri . " HTTP/" . $ this -> version , $ this -> headers -> render ( ) , ) ; if ( $ this -> method === 'POST' ) $ lines [ ] = $ this -> data ; $ lines = join ( "\r\n" , $ lines ) ; fwrite ( $ fp , $ lines ) ; //  send Request
 while ( ! feof ( $ fp ) ) //  receive Response
 $ result .= fgets ( $ fp , 1024 ) ; //  collect Response chunks
 fclose ( $ fp ) ; //  close Connection
 $ response = Net_HTTP_Response_Parser :: fromString ( $ result ) ; if ( count ( $ response -> getHeader ( 'Location' ) ) ) { $ location = array_shift ( $ response -> getHeader ( 'Location' ) ) ; $ this -> host = parse_url ( $ location -> getValue ( ) , PHP_URL_HOST ) ; $ this -> setPort ( parse_url ( $ location -> getValue ( ) , PHP_URL_PORT ) ) ; $ this -> setUri ( parse_url ( $ location -> getValue ( ) , PHP_URL_PATH ) ) ; return $ this -> send ( ) ; } return $ response ; }
Sends data via prepared Request.
@access		public
@return		Net_HTTP_Response
Sends data via prepared Request .