Modem-Help Forum Index Main Site
Modems
Downloads
Chips, Chipsets
Help [ Old Help ]
SearchAbuseAggregatorEFG
Modem-Help
Dedicated help on Modems
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Conteg :: Content Negotiation PHP Class :: v0.13 released

 
Post new topic   Reply to topic    Modem-Help Forum Index -> Site Info + Diary
View previous topic :: View next topic  
Author Message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6008
Location: Nottingham, England

PostPosted: Tue Feb 20, 2007 12:47 am    Post subject: Conteg :: Content Negotiation PHP Class :: v0.13 released Reply with quote

Conteg.include v0.10 PHP Class : Documentation : Overview
Conteg :: Content Negotiation PHP Class :: v0.12.3 released
Conteg downloads

This principally adds $referer and getReferer() to allow easy access to all details of the referring-page. In addition, the Class will now (by default) transform "404 Not Found" custom-error-pages to "410 Gone" pages when the scheme is HTTP/1.1, plus implements a fix for error-pages of < 513 bytes on MSIE pages, plus a small bug-fix in sendStatusHeader() (fixed no-status headers when HTTP/1.1 status attempted for a browser which declared HTTP/1.0 scheme).

Here are selected comments from the Class:
Code:
Conteg.include

 Content-Negotiation + Cache-Control for PHP-produced HTTP web-output
  - Request/Response Headers attempt to be RFC-compliant
  - Compression is load-balanced by default
  - Document-wide multi search/replace available
  - Referer (sic), Browser + OS-platform also reported
  - Single array-parameter switches negotiation on/off:

    No switches:   auto-negotiates Accept-Encoding (compression), User-Agent (+ Referer)
  Add:
   +Modified-date: auto-negotiates If-Modified-Since, If-Unmodified-Since
   +Expiry time:   auto-sends Expires
   +Etag:          auto-negotiates If-None-Match, If-Match, If-Range
   +Ranges:        auto-negotiates Range, If-Range
   +Charset:       auto-negotiates Accept-Charset
   +Language:      auto-negotiates Accept-Language
   +Media-Type     auto-negotiates Accept

    With the appropriate switches, the routine will auto-send the correct
   +304 Not Modified, 406 Not Acceptable, 412 Precondition Failed, 416 Requested
   +Range Not Satisfiable, 206 Partial content or 200 OK page + full headers.

    404/410 custom error-pages are possible. In addition, user-decided HTTP status
   +pages are possible (over-ridden only by 404/410 pages). Error-pages are auto-
   +fixed for MSIE browsers.

    All program defaults may be over-ridden.

 Notes:
 1 Compression extended from Gzip_encode v0.67s.3; see
   http://leknor.com/code/gziped.php for stats on how a page may compress.
 2 Class also reports Referer (sic), Browser + OS-platform;
      Referer:               see getReferer() for details
      Browser + OS-platform: active use made within negotiateEncoding().
                             Further reports on other browsers, etc welcomed.
 3 Global search/replace available via `search' parameter. Default is
   compression stats, if declared in text.
 4 This Class is aimed at delivery of webpages/files via http protocol, which
   implies HTTP Status 200, 206, 304, 406, 412 or 416 (all auto-encoded) or 404/410.
   A user-determined http status may also be declared; it will over-ride any program
   status except 404/410. See also sendStatusHeader().

 Change Log:
   0.13:    Added $referer, getReferer(), '404_to_410', $_no410,       18 Feb 07
           +'http_status', $_httpStatus, 'msie_error_fix',
           +$_noMSErrorFix + sendStatusHeader() bugfix.
   0.12.3:  Bugfix for 'expiry' (was always 1 hr) (thank you Bob).     04 Oct 06
   0.12.2:  Added $_num_cpu for SMP boxes (like mine!).                18 Aug 06
   0.12.1:  Added sendStatusHeader() + 404 responses (used to create   02 Ju1 06
           +custom Error-pages).
   0.12:    Added requestNoCache(), requestNoStore(),                  04 Jun 06
           +$_cache_control_response + $_cache_control_request arrays.
   0.11:    BugFix in _initResponse() [INM not tripped but IMS is];    13 Mar 06
           +'other_var' added to setup() (ref: weak eTags) (bugfix).   23 Feb 06
   0.10:    Gzip_encode rewritten; Request + Response headers added.   25 Aug 05
            Browser detect added to negotiateEncoding() to fix blanks. 09 Sep 05
            Content-Negotiation completed for compression-Encoding.    16 Sep 05

 Constructor parameter array

 These are all the possible array values within the single parameter supplied to
+the constructor, and acted upon within setup(), with defaults.
 Note: none of the following is required - these are the program defaults:

 array(
   '404'                => FALSE,                             // higher precedence than 'http_status'
   '404_to_410'         => TRUE,                              // see sendStatusHeader()
   'cache_control'      => array( 'macro' => 'cache-all' ),   // see setup()
   'charset'            => 'ISO-8859-1',
   'dupe_status_header' => TRUE,                              // see sendStatusHeader()
   'encodings'          => array( 'gzip','deflate','compress' ),
   'etag'               => '',
   'expiry'             => 3600,                              // secs after time()
   'http_status'        => NULL,                              // preferred to program-decided status
   'input'              => 'instream',                        // Apache-Notes
   'lang'               => 'en',
   'modified'           => NULL,                              // sets $last_modified to time()
   'msie_error_fix'     => TRUE,                              // avoid MSIE `friendly` error pages
   'noprint'            => FALSE,
   'other_var'          => '',                                // extra string to affect (weak) ETag
   'output'             => 'outstream',                       // Apache-Notes
   'prefer'             => array(),
   'ratio'              => 'ratio',                           // Apache-Notes
   'referer_lower_case' => TRUE,
   'search'             => array(),
   'type'               => 'text/html',
   'use_accept'         => FALSE,
   'use_accept_charset' => FALSE,
   'use_accept_encode'  => TRUE,
   'use_accept_lang'    => FALSE,
   'use_accept_ranges'  => FALSE,
   'use_apache_notes'   => FALSE,
   'use_content_lang'   => TRUE,
   'use_content_type'   => TRUE,
   'use_etag'           => FALSE,
   'weak_etag'          => TRUE
 )

The additions have resulted in many small changes throughout many parts of the Class, hence I cannot offer a simple sample of necessary code-changes. The new Class can, however, be used as a straight-forward replacement within any existing implementation. The only consideration will be that 404 pages under HTTP/1.1 will, by default, be transformed to 410 pages.

The new Class will be on the downloads section of the site shortly.

2009-04-16 Edited by AK
Edit Reason: Fixed URLs

_________________
Alex Kemp


Last edited by Alex Kemp on Thu Apr 16, 2009 2:20 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6008
Location: Nottingham, England

PostPosted: Tue Feb 20, 2007 2:25 am    Post subject: Conteg & MSIE `Friendly` Error Pages Reply with quote

By default, Conteg will now use the Microsoft-approved method to ensure that the content of custom error-pages is always displayed in Microsoft Internet Explorer (MSIE) 5 and 6. That is achieved by padding very small content until it is greater than 512 bytes in length. See compress() for the precise method employed.

This behaviour is switched by the following pairing within the Constructor parameter array:
Code:
'msie_error_fix' => TRUE

(if "FALSE", no attempt is made to pad content in any situation)

More Information:
I've known for a very long while that MSIE will show their infamous so-called "Friendly" error pages in preference to the server-crafted Error message (I'm unsure as I write of the behaviour of MSIE 7), but what I did not know until 2 or 3 weeks ago was that that behaviour is entirely governed by the size of the Error page.

Micro$oft have been particularly bad in this respect. Their original, flagship web-server Internet Information Services (IIS) 4 did not follow RFC 2616 and actually returned a "200 OK" HTTP status when sending an error page (see MS KB294807). IIS 5 has corrected that error, but the earlier behaviour has led to many so-called web experts giving out misleading information.

At the Client end, the default behaviour of MSIE has been to ignore the server-provided web-page for the following HTTP error-codes:
Quote:
Error 400
Error 403
Error 404
Error 405
Error 406
Error 408
Error 409
Error 410
Error 500
Error 501
Error 505
(see also MS KB218155)

The precise minimum page-size required to ignore the above error-content varies for each error, and is stored within the Registry. It is never any more than 512 bytes. The registry-location for this info has gone with MSIE7, so the above may no longer be MSIE's default behaviour. Frankly, I do not care.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6008
Location: Nottingham, England

PostPosted: Tue Feb 20, 2007 2:49 am    Post subject: 404/410 pages Reply with quote

Conteg introduced the means to easily provide custom error-pages at v0.12.1. These are signalled by the following pairing within the Constructor parameter array:
Quote:
'404' => TRUE
(default is 'FALSE')

Now at v0.13 the default action with "404 Not Found" pages is--when the browser supports HTTP/1.1--to transform them into "410 Gone" pages. This behaviour can be switched OFF with the following pairing within the Constructor parameter array:
Quote:
'404_to_410' => FALSE
(default is 'TRUE')

More Information:
'404' is a HTTP/1.0 status code with a meaning of "File (or page) Not Found". HTTP/1.1 introduced the '410' status code with a meaning of "File (or page) Gone" and, most of the time, it is the latter rather than the former that is wanted.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6008
Location: Nottingham, England

PostPosted: Tue Feb 20, 2007 3:21 am    Post subject: $referer, getReferer() Reply with quote

Conteg v0.13 makes the "Referer" header available via getReferer(). getReferer() returns an associative array which includes the original URI (always in it's original case) and also all the available parts of that URI, broken down using parse_url(), and by default lower-cased.

If you wish the uri-parts to be retained in original case, use the following pairing within the Constructor parameter array:
Quote:
'referer_lower_case' => FALSE
(default is 'TRUE')

These are the comments to getReferer():
Code:
getReferer() - The (array of parts of the) Referer (sic) string.

 These are the possible parts of the associative array returned:
    'uri'       - full, original referer URI; always present
    'scheme'
    'user'
    'pass'
    'host'
    'port'
    'path'
    'query'
    'fragment'

  note 1: at least `uri` + one other is present
  note 2: auto-urldecoded, (not `uri`)
  note 3: lower-cased if $_noReferLC == FALSE (default), (not `uri`)
  example URI: scheme://user:pass@host:port/path?query#fragment

 Returns $referer array/FALSE

- 16 Feb 07 added -AK


More Information:
Most browsers will, when they request a page, also send the page on which that link was found (the "referring" page). This is the "Referer" (sic) info, present within the Request-header sent by the browser.

parse_url(), which is used to obtain an array of the HTTP parts of the URI, uses the same PHP mechanism as that used to obtain the $_REQUEST and other arrays. This mechanism auto-urldecodes the URI, turning (as just one example) "%20" into " " (a space character).
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Modem-Help Forum Index -> Site Info + Diary All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2007 phpBB Group