<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: HTTP Status: 100 Continue</title>
	<atom:link href="http://benramsey.com/archives/http-status-100-continue/feed/" rel="self" type="application/rss+xml" />
	<link>http://benramsey.com/archives/http-status-100-continue/</link>
	<description>PHP and Other Techno-babble</description>
	<lastBuildDate>Wed, 04 Aug 2010 14:29:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sorgalla.com</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-330088</link>
		<dc:creator>sorgalla.com</dc:creator>
		<pubDate>Tue, 12 Jan 2010 14:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-330088</guid>
		<description>&lt;strong&gt;Ajax-Applikationen mit dem Zend Framework...&lt;/strong&gt;

Ajax wird heute in fast jeder modernen Webanwendung genutzt, bietet doch jedes gute Javascript-Framework mittlerweile einfache Möglichkeiten XHR-Anfragen abzusetzen. In diesem Artikel soll es aber nicht um die Client-Seite gehen, sondern darum, wie man...</description>
		<content:encoded><![CDATA[<p><strong>Ajax-Applikationen mit dem Zend Framework&#8230;</strong></p>
<p>Ajax wird heute in fast jeder modernen Webanwendung genutzt, bietet doch jedes gute Javascript-Framework mittlerweile einfache Möglichkeiten XHR-Anfragen abzusetzen. In diesem Artikel soll es aber nicht um die Client-Seite gehen, sondern darum, wie man&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Maynard</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-271284</link>
		<dc:creator>Glenn Maynard</dc:creator>
		<pubDate>Sun, 01 Feb 2009 20:33:41 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-271284</guid>
		<description>It&#039;s not just that it&#039;s respecting the header; that&#039;s the only way it can work with HTTP 1.1&#039;s keepalive.  This may have been different with HTTP 1.0 (which didn&#039;t do keep-alive without extensions, so servers might have got away with ignoring Content-Length and reading until the connection closed).

Telnet is line-buffering.  The server will actually respond as soon as you finish typing &quot;Foo&quot;, but telnet just isn&#039;t sending the data until you hit enter.  This can be confusing if you don&#039;t know about it, since it looks like it&#039;s something the server is doing, when it&#039;s actually the client.</description>
		<content:encoded><![CDATA[<p>It&#8217;s not just that it&#8217;s respecting the header; that&#8217;s the only way it can work with HTTP 1.1&#8217;s keepalive.  This may have been different with HTTP 1.0 (which didn&#8217;t do keep-alive without extensions, so servers might have got away with ignoring Content-Length and reading until the connection closed).</p>
<p>Telnet is line-buffering.  The server will actually respond as soon as you finish typing &#8220;Foo&#8221;, but telnet just isn&#8217;t sending the data until you hit enter.  This can be confusing if you don&#8217;t know about it, since it looks like it&#8217;s something the server is doing, when it&#8217;s actually the client.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Ramsey</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-271256</link>
		<dc:creator>Ben Ramsey</dc:creator>
		<pubDate>Sun, 01 Feb 2009 15:40:52 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-271256</guid>
		<description>I stand corrected. I felt certain that I could spoof the Content-Length header, but it appears that the server respects that header and only reads that much data and stops.

I did a quick test. On the server I placed this file:

[code]
if ($_SERVER[&#039;REQUEST_METHOD&#039;] == &#039;POST&#039;) {
    $entity = file_get_contents(&#039;php://input&#039;);
    echo &#039;Content-Length: &#039; . $_SERVER[&#039;CONTENT_LENGTH&#039;] . &quot;\n&quot;;
    echo &#039;Actual length: &#039; . strlen($entity) . &quot;\n&quot;;
    echo &#039;Entity body: &#039; . $entity . &quot;\n&quot;;
}
[/code]

From telnet, I posted this data:

[code]
POST /~ramsey/http/length.php HTTP/1.1
Host: localhost
Content-Length: 3

Foo bar. This is a longer entity than the Content-Lenth says.
[/code]

What I got back in response was:

[code]
Content-Length: 3
Actual length: 3
Entity body: Foo
[/code]

If I set &lt;code&gt;Content-Length&lt;/code&gt; to 100, however, the server appears to wait until I&#039;ve submitted the full 100 bytes, or it times outâ€”whichever comes first.

So, yeah, I&#039;ll put a note in the body of this post soon, but I&#039;ll also make a new blog post to explain my fallacy and I&#039;ll link to that post from here.

Thanks!</description>
		<content:encoded><![CDATA[<p>I stand corrected. I felt certain that I could spoof the Content-Length header, but it appears that the server respects that header and only reads that much data and stops.</p>
<p>I did a quick test. On the server I placed this file:</p>
<p>
<div class="hl-surround" ><div class="hl-main"><pre>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $entity = file_get_contents('php://input');
    echo 'Content-Length: ' . $_SERVER['CONTENT_LENGTH'] . &quot;\n&quot;;
    echo 'Actual length: ' . strlen($entity) . &quot;\n&quot;;
    echo 'Entity body: ' . $entity . &quot;\n&quot;;
}</pre></div></div>
</p>
<p>From telnet, I posted this data:</p>
<p>
<div class="hl-surround" ><div class="hl-main"><pre>POST /~ramsey/http/length.php HTTP/1.1
Host: localhost
Content-Length: 3

Foo bar. This is a longer entity than the Content-Lenth says.</pre></div></div>
</p>
<p>What I got back in response was:</p>
<p>
<div class="hl-surround" ><div class="hl-main"><pre>Content-Length: 3
Actual length: 3
Entity body: Foo</pre></div></div>
</p>
<p>If I set <code>Content-Length</code> to 100, however, the server appears to wait until I&#8217;ve submitted the full 100 bytes, or it times outâ€”whichever comes first.</p>
<p>So, yeah, I&#8217;ll put a note in the body of this post soon, but I&#8217;ll also make a new blog post to explain my fallacy and I&#8217;ll link to that post from here.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Maynard</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-271185</link>
		<dc:creator>Glenn Maynard</dc:creator>
		<pubDate>Sun, 01 Feb 2009 07:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-271185</guid>
		<description>The only way that can happen is with a Transfer-Encoding to compress the data, in which case the Content-Length header is illegal and should be explicitly ignored (4.4 #3).

If it&#039;s just a plain, non-chunked request (T-E: identity), you can&#039;t give a fake Content-Length, because the header itself defines the amount of data that&#039;s going to be read as the request body.  If you say Content-Length: 1, and then write a gigabyte of data, the server is only going to read the first byte as the request body, and the rest will be a new request...


Can you put a note in the post about 100-continue, so people who don&#039;t read comments aren&#039;t led astray?</description>
		<content:encoded><![CDATA[<p>The only way that can happen is with a Transfer-Encoding to compress the data, in which case the Content-Length header is illegal and should be explicitly ignored (4.4 #3).</p>
<p>If it&#8217;s just a plain, non-chunked request (T-E: identity), you can&#8217;t give a fake Content-Length, because the header itself defines the amount of data that&#8217;s going to be read as the request body.  If you say Content-Length: 1, and then write a gigabyte of data, the server is only going to read the first byte as the request body, and the rest will be a new request&#8230;</p>
<p>Can you put a note in the post about 100-continue, so people who don&#8217;t read comments aren&#8217;t led astray?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Ramsey</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-271158</link>
		<dc:creator>Ben Ramsey</dc:creator>
		<pubDate>Sun, 01 Feb 2009 03:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-271158</guid>
		<description>Glenn, after writing a lengthy reply in rebuttal to your message, I finally saw what you were getting at and retracted my reply.

What I missed in Section 14.20 of RFC 2616 was this: &quot;The server MUST respond with a 417 (Expectation Failed) status if any of the expectations cannot be met or, if there are other problems with the request, some other 4xx status.&quot;

Furthermore, Section 8.2.3 states: &quot;Upon receiving a request which includes an Expect request-header field with the &#039;100-continue&#039; expectation, an origin server MUST either respond with 100 (Continue) status and continue to read from the input stream, or respond with a final status code.&quot;

So, it seems the problem is that Ruby and Richardson got it wrong in &lt;em&gt;RESTful Web Services&lt;/em&gt; when they say: &quot;If the answer is no, the server sends a status code of 417 (&#039;Expectation Failed&#039;). The answer might be no because [...] 500 MB is just too big&quot; (pg. 250).

&gt; Be aware that the Content-Length header cannot be trusted.

I say this because Content-Length header can be spoofed easily. Someone can create a client to post arbitrary data to your service. If, for example, you only want to allow 50 MB uploads, and some malicious user wants to post something that&#039;s 100 MB, they can set the Content-Length header to 50 MB and put however much data they wish in the entity body. So, you can&#039;t necessarily take the Content-Length at face value; you should also validate that the content of the entity body is not greater than the length you want to accept.</description>
		<content:encoded><![CDATA[<p>Glenn, after writing a lengthy reply in rebuttal to your message, I finally saw what you were getting at and retracted my reply.</p>
<p>What I missed in Section 14.20 of RFC 2616 was this: &#8220;The server MUST respond with a 417 (Expectation Failed) status if any of the expectations cannot be met or, if there are other problems with the request, some other 4xx status.&#8221;</p>
<p>Furthermore, Section 8.2.3 states: &#8220;Upon receiving a request which includes an Expect request-header field with the &#8216;100-continue&#8217; expectation, an origin server MUST either respond with 100 (Continue) status and continue to read from the input stream, or respond with a final status code.&#8221;</p>
<p>So, it seems the problem is that Ruby and Richardson got it wrong in <em>RESTful Web Services</em> when they say: &#8220;If the answer is no, the server sends a status code of 417 (&#8216;Expectation Failed&#8217;). The answer might be no because [...] 500 MB is just too big&#8221; (pg. 250).</p>
<p>> Be aware that the Content-Length header cannot be trusted.</p>
<p>I say this because Content-Length header can be spoofed easily. Someone can create a client to post arbitrary data to your service. If, for example, you only want to allow 50 MB uploads, and some malicious user wants to post something that&#8217;s 100 MB, they can set the Content-Length header to 50 MB and put however much data they wish in the entity body. So, you can&#8217;t necessarily take the Content-Length at face value; you should also validate that the content of the entity body is not greater than the length you want to accept.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Maynard</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-271122</link>
		<dc:creator>Glenn Maynard</dc:creator>
		<pubDate>Sun, 01 Feb 2009 00:46:59 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-271122</guid>
		<description>&gt; Let&#039;s say your service limits uploads to 100MB. In that case, you would return a 417 Expectation Failed including a reason for the failure in the body of the response.

This is incorrect.  417 means that an Expect you sent is unsupported; for example, if you send &quot;Expect: bacon&quot;, and the server doesn&#039;t support that, then it responds with 417.  Responding with 417 because the request was going to be too large badly violates the spec.

The purpose of 100-continue is to give the server a chance to give an error to the client before it sends the request body, rather than after.  If doing that required that all of those detailed 4xx/5xx errors were turned into an opaque 417 and useless, plain language errors in the body, it would be useless.

&gt; For the specific example of uploading large files, what do you think about returning 413 (Request Entity Too Large)? 

This is the correct behavior.

&gt; Be aware that the Content-Length header cannot be trusted. 

I&#039;m not sure what this means.  Except for chunked connections, Content-Length must be trusted, or you won&#039;t be able to tell where a request/response body ends.</description>
		<content:encoded><![CDATA[<p>> Let&#8217;s say your service limits uploads to 100MB. In that case, you would return a 417 Expectation Failed including a reason for the failure in the body of the response.</p>
<p>This is incorrect.  417 means that an Expect you sent is unsupported; for example, if you send &#8220;Expect: bacon&#8221;, and the server doesn&#8217;t support that, then it responds with 417.  Responding with 417 because the request was going to be too large badly violates the spec.</p>
<p>The purpose of 100-continue is to give the server a chance to give an error to the client before it sends the request body, rather than after.  If doing that required that all of those detailed 4xx/5xx errors were turned into an opaque 417 and useless, plain language errors in the body, it would be useless.</p>
<p>> For the specific example of uploading large files, what do you think about returning 413 (Request Entity Too Large)? </p>
<p>This is the correct behavior.</p>
<p>> Be aware that the Content-Length header cannot be trusted. </p>
<p>I&#8217;m not sure what this means.  Except for chunked connections, Content-Length must be trusted, or you won&#8217;t be able to tell where a request/response body ends.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Kubb</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-230151</link>
		<dc:creator>Dan Kubb</dc:creator>
		<pubDate>Mon, 18 Aug 2008 07:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-230151</guid>
		<description>For the specific example of uploading large files, what do you think about returning 413 (Request Entity Too Large)?  It seems that this provides the user agent with more information than a 417 (Expectation Failed) status does, and is more specific in describing the problem.</description>
		<content:encoded><![CDATA[<p>For the specific example of uploading large files, what do you think about returning 413 (Request Entity Too Large)?  It seems that this provides the user agent with more information than a 417 (Expectation Failed) status does, and is more specific in describing the problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akki</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-172476</link>
		<dc:creator>Akki</dc:creator>
		<pubDate>Wed, 30 Apr 2008 14:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-172476</guid>
		<description>Hi,

I was wondering if there was a response status to allow a large file to be &quot;served&quot; in parts and in just one response?

I need a way to do this and I&#039;d be grateful if the pedant offers succor :)

thanks!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I was wondering if there was a response status to allow a large file to be &#8220;served&#8221; in parts and in just one response?</p>
<p>I need a way to do this and I&#8217;d be grateful if the pedant offers succor <img src='http://benramsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Ramsey</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-171196</link>
		<dc:creator>Ben Ramsey</dc:creator>
		<pubDate>Mon, 28 Apr 2008 14:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-171196</guid>
		<description>Ralf, I recommend you read the section in the PHP manual on the use of the &lt;code&gt;&quot;header()&quot;:http://php.net/header &lt;/code&gt; function. In short, if you need to send the &lt;code&gt;100 Continue&lt;/code&gt; code, you may do so like this:

&lt;code&gt;header(&#039;HTTP/1.1 100 Continue&#039;);&lt;/code&gt;

If you are building a client application and need to check for the &lt;code&gt;100 Continue&lt;/code&gt; and other headers in a response received from the server, you can you &quot;curl&quot;:http://php.net/curl, &quot;fsockopen&quot;:http://us3.php.net/fsockopen, or something like &quot;Zend_Http&quot;:http://framework.zend.com/manual/en/zend.http.html.

Be aware that the Content-Length header cannot be trusted. The value it contains should only be considered for informational purposes and may not be the actual size of the uploaded file. However, with a request containing an &lt;code&gt;Expect: 100-continue&lt;/code&gt; header, there won&#039;t be a file uploaded, so you have only the Content-Length header to go by for determining whether or not to tell the client to continue sending the full request.</description>
		<content:encoded><![CDATA[<p>Ralf, I recommend you read the section in the PHP manual on the use of the <code><a href="http://php.net/header">header()</a> </code> function. In short, if you need to send the <code>100 Continue</code> code, you may do so like this:</p>
<p><code>header(&#8216;HTTP/1.1 100 Continue&#8217;);</code></p>
<p>If you are building a client application and need to check for the <code>100 Continue</code> and other headers in a response received from the server, you can you <a href="http://php.net/curl">curl</a>, <a href="http://us3.php.net/fsockopen">fsockopen</a>, or something like <a href="http://framework.zend.com/manual/en/zend.http.html">Zend_Http</a>.</p>
<p>Be aware that the Content-Length header cannot be trusted. The value it contains should only be considered for informational purposes and may not be the actual size of the uploaded file. However, with a request containing an <code>Expect: 100-continue</code> header, there won&#8217;t be a file uploaded, so you have only the Content-Length header to go by for determining whether or not to tell the client to continue sending the full request.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ralf Jones</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-171145</link>
		<dc:creator>Ralf Jones</dc:creator>
		<pubDate>Mon, 28 Apr 2008 11:33:18 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-171145</guid>
		<description>Can use 100 in PHP ?
As I know, PHP will save the file uploaded to /tmp first whatever u do
How to check &quot;Content-Length&quot; before the file saved?</description>
		<content:encoded><![CDATA[<p>Can use 100 in PHP ?<br />
As I know, PHP will save the file uploaded to /tmp first whatever u do<br />
How to check &#8220;Content-Length&#8221; before the file saved?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Harrison</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-168409</link>
		<dc:creator>Richard Harrison</dc:creator>
		<pubDate>Wed, 23 Apr 2008 23:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-168409</guid>
		<description>Amazon&#039;s S3 service uses this (if you want to play around with something in the wild).</description>
		<content:encoded><![CDATA[<p>Amazon&#8217;s S3 service uses this (if you want to play around with something in the wild).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: julien-pauli</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-168067</link>
		<dc:creator>julien-pauli</dc:creator>
		<pubDate>Wed, 23 Apr 2008 10:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-168067</guid>
		<description>Keep going Ben, HTTP is a wonderfull and powerfull protocol, show us what it can do in real world ! ;-)
(Chris Shifflet&#039;s HTTP developer&#039;s Handbook is very nice)</description>
		<content:encoded><![CDATA[<p>Keep going Ben, HTTP is a wonderfull and powerfull protocol, show us what it can do in real world ! <img src='http://benramsey.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <br />
(Chris Shifflet&#8217;s HTTP developer&#8217;s Handbook is very nice)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Flickinger</title>
		<link>http://benramsey.com/archives/http-status-100-continue/comment-page-1/#comment-167867</link>
		<dc:creator>Christian Flickinger</dc:creator>
		<pubDate>Wed, 23 Apr 2008 02:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://benramsey.com/archives/http-status-100-continue/#comment-167867</guid>
		<description>Great post! You always enlighten me on things I take for granted... like http status codes!

They seem so hidden and untouchable, and you just want to use the standard 300/404/500... 

The uses for some of them are very intriguing, and at least this one, 100, can significantly reduce overhead... instead of sending that 100mb file each time, then verifying details.. you can now verify before sending! GENIUS.</description>
		<content:encoded><![CDATA[<p>Great post! You always enlighten me on things I take for granted&#8230; like http status codes!</p>
<p>They seem so hidden and untouchable, and you just want to use the standard 300/404/500&#8230; </p>
<p>The uses for some of them are very intriguing, and at least this one, 100, can significantly reduce overhead&#8230; instead of sending that 100mb file each time, then verifying details.. you can now verify before sending! GENIUS.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
