Recent changes RSS feed
 

PHP HTTP Response Handling Summary

See HttpServletResponse for more information on how Java handles HTTP Responses.

See PHP HTTP Request Handling Summary for more information on how PHP handles HTTP requests.

HTTP Response Content

PHP has a fairly simple output mechanism compared to Java Servlets.

  • print - Output one or more strings
  • printf - Output formated strings
  • echo - Output one or more strings (as a function)

The Output Control Functions provide control over the buffering of the content output of the request. They also provide a simple mechanism to stack output filters. See InterceptingFilter.

output buffer configuration settings (ini)

  • output_buffering - enable buffering for all requests
  • output_handler - Register an output handling function. Same as ob_start.
  • implicit_flush - flush output after every output block (echo, print or printf)

Session Handling Functions provide the capability to use url based session Ids in the content output.

  • session.use_trans_sid - when this option is enabled, relative URIs in the response output will be rewritten to contain a session Id.
  • url_rewriter.tags - specifies which html tags are rewritten to include session information.

The Zlib Compression Functions can compress output on-the-fly.

Zlib compression configuration options:

  • zlib.output_compression - Whether to transparently compress pages
  • zlib.output_compression_level - Compression level used for transparent output compression
  • zlib.output_handler - similiar to output_handler

HTTP Response Headers

Basic HTTP Functions.

Output compression configuration

  • zlib.output_compression - outputs Content-Encoding and Vary headers when content is compressed.

Several configuration options control how the php session handling functions output cookies for tracking sessions.

  • session.auto_start - specifies whether the session module starts a session automatically
  • session.name - Used as the cookie name
  • session.cookie_lifetime - How long should the browser store the cookie
  • session.cookie_path
  • session.cookie_domain
  • session.cookie_secure
  • session.use_cookies - specifies whether the module will use cookies to store the session id on the client side
  • session.use_only_cookies - specifies whether the module will only use cookies to store the session id on the client side

functions controling how cookies are output during session handling.

Configuration options controlling page caching during a session:

  • session.cache_limiter - specifies cache control method to use for session page
  • session.cache_expire - specifies time-to-live for cached session pages

Functions controlling page caching during a session:

Apache specific functions configuration options

  • last_modified - send PHP scripts modification date as Last-Modified: header for the request.

HTTP Response Status

The header function has special case logic to also set the response status code. When the header paramter to the header() function begins with HTTP/, Status:, or Location:, the HTTP response status code is modified.

See HTTP authentication with PHP for more information about setting the response status.

Web Server Interface

Apache specific functions for response processing

HTTP Response Header / PHP Cross Reference

Content-Encoding

The zlib.output_compression configuration option or ob_gzhandler output handler can output Content-Encoding: gzip or Content-Encoding: deflate headers.

Content-Length

The zlib.output_compression configuration option or ob_gzhandler output handler can output Content-Length headers.

Content-Type

The mb_output_handler function and the configuration option mbstring.http_output can add charset information to the Content-Type headers.

Last-Modified

The last_modified configuration option send PHP scripts modification date as Last-Modified: header for the request. See Apache specific functions.

Set-Cookie

The setcookie function is the standard API for developers to output this header. PHP Session Handling Functions Will also set a cookie for tracking session Ids.

Vary

The zlib.output_compression configuration option or ob_gzhandler output handler can output Vary: Accept-Encoding headers.

 
php/http_response_handling.txt · Last modified: 2006/12/09 17:15
 
Hosting for this site donated by Procata PHP Development