A Few More Options

Below are a few other stream context options for the HTTP streams wrapper that may prove useful.

  • 'user_agent’ allows you to set the user agent string to use in the operation. This can also be set manually by specifying a value for the User-Agent header in the 'header’ context option value.
  • 'max_redirects’ is used to set the maximum number of redirections that the operation will process prior to assuming that the application is misbehaving and terminating the request. This option is only available in PHP 5.1.0 and up and uses a default value of 20.
  • 'timeout’ is used to set a maximum limit on the amount of time in seconds that a read operation may be allowed to execute before it is terminated. It defaults to the value of the default_socket_timeout PHP configuration setting.

All other features utilizing headers must be implemented manually by specifying request headers in the 'header’ context option and checking either $http_response_header or the 'wrapper_data’ index of the array returned by the stream_get_meta_data function for response headers.


© HTTP Streams Wrapper — Web Scraping

>>> Back to TABLE OF CONTENTS <<<
Category: Article | Added by: Marsipan (30.08.2014)
Views: 375 | Rating: 0.0/0
Total comments: 0
avatar