GuzzleHttpPsr7parse_request

Parses a request message string into a request object.

Description

GuzzleHttp\Psr7\parse_request( (string) $message ); 

Parameters (1)

0. $message (string)
Request message string.

Usage

  1. if ( !function_exists( 'GuzzleHttp\Psr7\parse_request' ) ) { 
  2. require_once '/lib/Azure/GuzzleHttp/Psr7/functions.php'; 
  3.  
  4. // Request message string. 
  5. $message = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = GuzzleHttp\Psr7\parse_request($message); 
  9.  

Defined (1)

The function is defined in the following location(s).

/lib/Azure/GuzzleHttp/Psr7/functions.php  
  1. function parse_request($message) 
  2. $data = _parse_message($message); 
  3. $matches = []; 
  4. if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { 
  5. throw new \InvalidArgumentException('Invalid request string'); 
  6. $parts = explode(' ', $data['start-line'], 3); 
  7. $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; 
  8.  
  9. $request = new Request( 
  10. $parts[0],  
  11. $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1],  
  12. $data['headers'],  
  13. $data['body'],  
  14. $version 
  15. ); 
  16.  
  17. return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);