2

I'm almost newby to nodejs. I'm working on a small nodejs micro-service and its running well. But as per recent requirement this service need to support HTTP/1.1 pipeline. But I'm failing to find in nodejs doc that how to enable/support that.

Please guide me find appropriate doc/module/resource to implement HTTP/1.1 pipeline.

Thanks.

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164

1 Answers1

3

Comments from @shaochuancs and @Helen are about nodejs http client.

If you need a server implementation of HTTP pipeline that depends entirely on the the nodejs core library.

HTTP server-side pipelining support is built-in and already OK in nodejs (I've just made the tests on tested on v5.5.0 v7.0.9 and v6.2.1).

To test pipelining support simply chain two HTTP request in the same tcp/ip connection. You can do it using telnet or netcat (nc).

# telnet, connecting to port 80, chaining 2 requests on /login
# for host foo.com
(echo -en "GET /login HTTP/1.1\nHost: foo.com\nConnection: keep-alive\n\nGET /login HTTP/1.1\nHost: foo.com\n\n"; sleep 10) | telnet localhost 80
# same thing using printf and netcat
printf "GET /login HTTP/1.1\r\nHost: foo.com\r\nConnection: keep-alive\r\n\r\nGET /login HTTP/1.1\r\nHost: foo.com\r\n\r\n" | nc -q 10 localhost 80

Then count the number of responses, you should get 2 (or 1 if pipelining is not supported). Search for 'HTTP/1.1 200 OK' in the output.

regilero
  • 29,806
  • 6
  • 60
  • 99