W3C home > Mailing lists > Public > ietf-http-wg@w3.org > October to December 2016

Re: New Version Notification for draft-kazuho-early-hints-status-code-00.txt

From: Julian Reschke <julian.reschke@gmx.de>
Date: Tue, 8 Nov 2016 15:21:22 +0100
To: Cory Benfield <cory@lukasa.co.uk>, Kazuho Oku <kazuhooku@gmail.com>
Cc: HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <c7b33b3d-8cab-5621-2c74-14e21a5a3885@gmx.de>
On 2016-10-31 19:21, Cory Benfield wrote:
> ...
> While I’m here, I’d like to discuss section 3. To provide some data points, most of the HTTP/1.1 clients in the Python ecosystem will not handle a new 1XX status code very well. A quick survey of the ecosystem suggests that the following tools will all misbehave:
>
> - every standard library http client (urllib, urllib2, httplib), all of which treat only “100 Continue” specially: the rest will treat the 103 header block as the final response and, because it MUST NOT have a content-length, will read until connection close.
> - every third-party library built on top of those tools, including urllib3, Requests, and httplib2, which inherit their misbehaviour.
> - aiohttp, which special-cases 100 and 101 but not any others
> - Twisted’s client, which special-cases 100
> ...

FWIW,

I just did a small Java test with a) JDK's URLConnection and b) Apache 
HTTP client 4.5.x.

a) Works in that it returns the correct response, but only after waiting 
for a timeout to occur it seems (needs to be investigated)

b) Works properly.

Neither API exposes the intermediate status, but at least for b) it 
looks like a relatively simple change.

-- snip --
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;

public class Test103 {

     public static void main(String[] args) throws IOException {
         apache();
         java();
     }

     private static void apache() throws IOException {
         HttpClient c = HttpClientBuilder.create().build();
         HttpGet get = new HttpGet("https://nghttp2.org/?103-eh");
         HttpResponse resp = c.execute(get);
         System.out.println(resp.getStatusLine());
         System.out.println(EntityUtils.toString(resp.getEntity()));
     }

     private static void java() throws IOException {
         URL test = new URL("https://nghttp2.org/?103-eh");
         InputStream is = test.openConnection().getInputStream();
         byte[] bytes = readFully(is);
         System.out.println(new String(bytes));
     }

     public static byte[] readFully(InputStream is) throws IOException {
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         int nRead;
         byte[] data = new byte[16384];

         while ((nRead = is.read(data, 0, data.length)) != -1) {
             buffer.write(data, 0, nRead);
         }

         buffer.flush();

         return buffer.toByteArray();
     }
}
-- snip --

Best regards, Julian
Received on Tuesday, 8 November 2016 14:21:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 8 November 2016 14:22:04 UTC