OAuthCommonHttpClientAbstractClient

Abstract HTTP client.

Defined (1)

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

/lib/PHPoAuthLib/src/OAuth/Common/Http/Client/AbstractClient.php  
  1. abstract class AbstractClient implements ClientInterface 
  2. /** 
  3. * @var string The user agent string passed to services 
  4. */ 
  5. protected $userAgent; 
  6.  
  7. /** 
  8. * @var int The maximum number of redirects 
  9. */ 
  10. protected $maxRedirects = 5; 
  11.  
  12. /** 
  13. * @var int The maximum timeout 
  14. */ 
  15. protected $timeout = 15; 
  16.  
  17. /** 
  18. * Creates instance 
  19. * @param string $userAgent The UA string the client will use 
  20. */ 
  21. public function __construct($userAgent = 'PHPoAuthLib') 
  22. $this->userAgent = $userAgent; 
  23.  
  24. /** 
  25. * @param int $redirects Maximum redirects for client 
  26. * @return ClientInterface 
  27. */ 
  28. public function setMaxRedirects($redirects) 
  29. $this->maxRedirects = $redirects; 
  30.  
  31. return $this; 
  32.  
  33. /** 
  34. * @param int $timeout Request timeout time for client in seconds 
  35. * @return ClientInterface 
  36. */ 
  37. public function setTimeout($timeout) 
  38. $this->timeout = $timeout; 
  39.  
  40. return $this; 
  41.  
  42. /** 
  43. * @param array $headers 
  44. */ 
  45. public function normalizeHeaders(&$headers) 
  46. // Normalize headers 
  47. array_walk( 
  48. $headers,  
  49. function (&$val, &$key) { 
  50. $key = ucfirst(strtolower($key)); 
  51. $val = ucfirst(strtolower($key)) . ': ' . $val; 
  52. );