Location: PHPKode > scripts > HTTP Headers Utility > http-headers-utility/HTTP_Headers_Util.html
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN' 'http://www.w3.org/TR/REC-html40/loose.dtd'>
<!--NewPage-->
<html>
<head>
	<!-- Generated by PhpDoc date: 'Thu, 23 Jan 2003 05:50:11 +0000' -->
	<title>Docs For Class HTTP_Headers_Util</title>
<link rel ='stylesheet' type='text/css' href='stylesheet.css' title='style'>
</head>
<body>
<table width="99%" border="0" class="pagetop" cellpadding="4">
	<tr>
		<td align="left"><a href="../classtrees_default.html">Class Trees</a></td>
	</tr>
</table>

<!-- Start of Class Data -->
<h2 class="class-heading">Class HTTP_Headers_Util</h2>

<pre class="class-tree">
HTTP_Headers_Util
</pre>

<span class="located-in">Located in: Program_Root/HTTP_Headers_Util.php</span>

<hr>

<!-- ========== Info from phpDoc block ========= -->
<b class="class-description">HTTP Headers Util - Header value parsing utility functions</b>
<pre class="class-full-description">
This class is based on HTTP::Headers::Util from Perl's LWP 
&lt;http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/HTTP/Headers/Util.pm&gt;
by Gisle Aas.
The text here is copied from the documentation of the above, obviously
slightly modified as this is PHP not Perl. 

SYNOPSIS

$values = HTTP_Headers_Util::split_header_words($header_value);

DESCRIPTION

This class provides a few functions that helps parsing and
construction of valid HTTP header values.
</pre>
<ul class="docblock">
	
	<li><b>Package</b> - <code>default</code></li>
	
	<li><b>Static</b> - <code></code></li>
	
</ul>

<hr>
<h2 class="section">Classes extended from HTTP_Headers_Util:</h2>

<hr>
<!-- should have constructor at some point -->
<!-- =========== Method SUMMARY =========== -->
<a name='Method_summary'><!-- --></a>
<h2 class="section">Method Summary</h2>
<table border='1' cellpadding='3' cellspacing='0' width='100%'>

	
	<!-- =========== Summary =========== -->
	<tr class="TableRowColor">
	<td align="right" valign="top" width="1%"><font size="-1"><code>&nbsp;string</code></font></td>
	<td align="left" valign="top" width="100%">
	<a href="HTTP_Headers_Util.html#join_header_words" class="method-name-summary">join_header_words ( $header_values )</a>
	<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;join_header_words</td>
	</tr>
	
	<!-- =========== Summary =========== -->
	<tr class="TableRowColor">
	<td align="right" valign="top" width="1%"><font size="-1"><code>&nbsp;array</code></font></td>
	<td align="left" valign="top" width="100%">
	<a href="HTTP_Headers_Util.html#split_header_words" class="method-name-summary">split_header_words ( $header_values )</a>
	<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;split_header_words</td>
	</tr>
	
</table>

<hr>
<!-- =========== VAR SUMMARY =========== -->
<a name='var_summary'><!-- --></a>
<h2 class="section">Class Variable Summary</h2>

<table border='1' cellpadding='3' cellspacing='0' width='100%'>

	
</table>

<hr>
<!-- =========== VAR INHERITED =========== -->
<a name='vars_inherited'><!-- --></a>
<h2 class="section">Inherited Class Variable Summary</h2>

<table border='1' cellpadding='3' cellspacing='0' width='100%'>

	
</table>

<hr>
<!-- =========== INHERITED METHOD SUMMARY =========== -->
<A NAME='functions_inherited'><!-- --></A>
<h2 class="section">Inherited Method Summary</h2>

<table border='1' cellpadding='3' cellspacing='0' width='100%'>

	
</table>

<hr>
<!-- ============ VARIABLE DETAIL =========== -->

<a name="variable_detail"></a>
<h2 class="section">Variable Detail</h2>



<hr>
<!-- ============ FUNCTION DETAIL =========== -->

<a name='function_detail'></a>
<h2 class="section">Method Detail</h2>


<a name='join_header_words'><!-- --></a><h3>join_header_words</h3>
<table>
  <tr>
    <td valign="top"><code>string</code>&nbsp; <b>join_header_words ( $header_values )</b></td>
  </tr>
  <tr>
    <td><br />
	  <div class="method-detailed-block">
		
		<!-- ========== Info from phpDoc block ========= -->
<b class="function-description">join_header_words</b>
<pre class="function-full-description">This will do the opposite of the conversion done by split_header_words().
It takes a list of anonymous arrays as arguments (or a list of
key/value pairs) and produces a single header value.  Attribute values
are quoted if needed.

Example:

   join_header_words(array(array(&quot;text/plain&quot; =&gt; null, &quot;charset&quot; =&gt; &quot;iso-8859/1&quot;)));
   join_header_words(array(&quot;text/plain&quot; =&gt; null, &quot;charset&quot; =&gt; &quot;iso-8859/1&quot;));

will both return the string:

   text/plain; charset=&quot;iso-8859/1&quot;</pre>
<dl>
	<dt>Function Parameters:</dt>
	
	<dd>- <code>array $header_values: </code></dd>
	

	<dt>Function Info:</dt>
	
	<dd><b>Static</b> - <code></code></dd>
	
</dl>

	  </div>
    </td>
  </tr>
</table>
<hr>

<a name='split_header_words'><!-- --></a><h3>split_header_words</h3>
<table>
  <tr>
    <td valign="top"><code>array</code>&nbsp; <b>split_header_words ( $header_values )</b></td>
  </tr>
  <tr>
    <td><br />
	  <div class="method-detailed-block">
		
		<!-- ========== Info from phpDoc block ========= -->
<b class="function-description">split_header_words</b>
<pre class="function-full-description">This function will parse the header values given as argument into a
array containing key/value pairs.  The function
knows how to deal with &quot;,&quot;, &quot;;&quot; and &quot;=&quot; as well as quoted values after
&quot;=&quot;.  A list of space separated tokens are parsed as if they were
separated by &quot;;&quot;.

If the $header_values passed as argument contains multiple values,
then they are treated as if they were a single value separated by
comma &quot;,&quot;.

This means that this function is useful for parsing header fields that
follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
the requirement for tokens).

  headers           = #header
  header            = (token | parameter) *( [&quot;;&quot;] (token | parameter))

  token             = 1*&lt;any CHAR except CTLs or separators&gt;
  separators        = &quot;(&quot; | &quot;)&quot; | &quot;&lt;&quot; | &quot;&gt;&quot; | &quot;@&quot;
                    | &quot;,&quot; | &quot;;&quot; | &quot;:&quot; | &quot;\&quot; | &lt;&quot;&gt;
                    | &quot;/&quot; | &quot;[&quot; | &quot;]&quot; | &quot;?&quot; | &quot;=&quot;
                    | &quot;{&quot; | &quot;}&quot; | SP | HT

  quoted-string     = ( &lt;&quot;&gt; *(qdtext | quoted-pair ) &lt;&quot;&gt; )
  qdtext            = &lt;any TEXT except &lt;&quot;&gt;&gt;
  quoted-pair       = &quot;\&quot; CHAR

  parameter         = attribute &quot;=&quot; value
  attribute         = token
  value             = token | quoted-string

Each header is represented by an anonymous array of key/value
pairs.  The value for a simple token (not part of a parameter) is null.
Syntactically incorrect headers will not necessary be parsed as you
would want.

This is easier to describe with some examples:

   split_header_words('foo=&quot;bar&quot;; port=&quot;80,81&quot;; discard, bar=baz');
   split_header_words('text/html; charset=&quot;iso-8859-1&quot;);
   split_header_words('Basic realm=&quot;\&quot;foo\\bar\&quot;&quot;');

will return

   [foo=&gt;'bar', port=&gt;'80,81', discard=&gt;null], [bar=&gt;'baz']
   ['text/html'=&gt;null, charset=&gt;'iso-8859-1']
   [Basic=&gt;null, realm=&gt;'&quot;foo\bar&quot;']</pre>
<dl>
	<dt>Function Parameters:</dt>
	
	<dd>- <code>mixed $header_values: string or array</code></dd>
	

	<dt>Function Info:</dt>
	
	<dd><b>Static</b> - <code></code></dd>
	
</dl>

	  </div>
    </td>
  </tr>
</table>
<hr>




<div align="center" class="footer">
Generated by <a href="http://phpdocu.sourceforge.net" target="_blank">phpDocumentor</a>
</div>

</body>
</html>
Return current item: HTTP Headers Utility