Ah, wait, the content length thing doesn't seem to be all that certain. I modified my node server to put a line ending on the output, and it still reports 59 characters (which is now, presumably correct.) The client still crashes the same way.
meanwhile, I'll try it with a JAX-RS based server instead. On Tue, May 15, 2018 at 7:25 AM Simon Roberts < si...@dancingcloudservices.com> wrote: > Daniel: Thanks, it did seem improbable, but seemed to be the only common > factor. But I suspect Joakim's astute observation is more relevant. > > I'm running on Linux, not Mac, and t's just a thrown together node.js > server. I guess that means the real bug is probably in node, though one > would think that the Java implementation should be robust enough to at > least not crash ( > > I'll see if I can a) make it work if I run against say a JAX-RS server, > and b) file an appropriate bug. > > Thanks everyone. > > > On Tue, May 15, 2018 at 5:38 AM Joakim Erdfelt <joakim.erdf...@gmail.com> > wrote: > >> You're server is reporting the wrong Content-Length. >> >> "<html><body><h1>Heading</h1><p>Some Text</p></body></html>" is 59 >> characters >> >> But the server said "Content-Length: 58" >> >> Also, "Connection: keep-alive" is a HTTP/1.0 concept only, but is being >> reported on your HTTP/1.1 request/response improperly. >> >> >> On Mon, May 14, 2018 at 7:20 PM, Simon Roberts < >> si...@dancingcloudservices.com> wrote: >> >>> >>> I have a very simple attempt to use the Java 10 / incubator httpclient >>> api. It works on "regular" resources, but fails horribly when attempting to >>> get things from localhost. It fails using 127.0.0.1, the actual >>> non-loopback IP, and the name localhost. The server is running, and >>> presenting a very simple web page (I originally tried json, but have since >>> simplified it attempting to find out what's amiss). >>> >>> The code is as simple as I can imagine (and that might be the problem :) >>> >>> -------------------------------------------------------------- >>> HttpClient client = HttpClient.newHttpClient(); >>> URI uri = URI.create("http://192.168.1.102:8080/index.html"); >>> >>> HttpRequest getRequest = HttpRequest.newBuilder() >>> .uri(uri).GET().build(); >>> >>> HttpResponse<String> response = client.send(getRequest, >>> HttpResponse.BodyHandler.asString()); >>> System.out.println("response to get: " + response.body()); >>> -------------------------------------------------------------- >>> >>> The error prints a long stack trace, which I suppose I must post in its >>> entiretly: >>> >>> -------------------------------------------------------------- >>> >>> WARNING: Using incubator modules: jdk.incubator.httpclient >>> Exception in thread "main" java.io.EOFException: EOF reached while >>> reading >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:507) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$InternalReadPublisher$ReadSubscription.signalCompletion(SocketTube.java:551) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:728) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$SocketFlowTask.run(SocketTube.java:171) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.internal.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.internal.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.internal.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:675) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:829) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:243) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:769) >>> at >>> jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:731) >>> >>> Process finished with exit code 1 >>> -------------------------------------------------------------- >>> >>> If I use a curl to make the request of my (node/express) server, I get: >>> >>> -------------------------------------------------------------- >>> $ curl -v http://localhost:8080/index.html >>> * Trying 127.0.0.1... >>> * Connected to localhost (127.0.0.1) port 8080 (#0) >>> > GET /index.html HTTP/1.1 >>> > Host: localhost:8080 >>> > User-Agent: curl/7.47.0 >>> > Accept: */* >>> > >>> < HTTP/1.1 200 OK >>> < X-Powered-By: Express >>> < Content-Type: text/html; charset=utf-8 >>> < Content-Length: 58 >>> < ETag: W/"3a-EwoPOQKsJivlqZA3z/ulngzMv9U" >>> < Date: Tue, 15 May 2018 00:18:47 GMT >>> < Connection: keep-alive >>> < >>> * Connection #0 to host localhost left intact >>> <html><body><h1>Heading</h1><p>Some Text</p></body></html> >>> -------------------------------------------------------------- >>> >>> Anyone able to tell me what I'm doing wrong? >>> >>> TIA! >>> >>> >>> >> > > -- > Simon Roberts > (303) 249 3613 > > -- Simon Roberts (303) 249 3613