hisco / http2-client

Transparently make http request to both http1 / http2 server.
https://www.npmjs.com/package/http2-client
MIT License
33 stars 14 forks source link

Example returns a 404 #1

Closed paambaati closed 6 years ago

paambaati commented 6 years ago

When I execute the usage example, I get a 404 from the HTTP URL.

Url : http://www.example.com/
Status : 404
HttpVersion : 1.1

Url : https://www.example.com/
Status : 200
HttpVersion : 2.0

I've verified that http://www.example.com/ actually works and is a valid URL.

curl -i -v "http://www.example.com/"
*   Trying 93.184.216.34...
* TCP_NODELAY set
* Connected to www.example.com (93.184.216.34) port 80 (#0)
> GET / HTTP/1.1
> Host: www.example.com
> User-Agent: curl/7.61.0
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Cache-Control: max-age=604800
Cache-Control: max-age=604800
< Content-Type: text/html
Content-Type: text/html
< Date: Tue, 21 Aug 2018 04:13:39 GMT
Date: Tue, 21 Aug 2018 04:13:39 GMT
< Etag: "1541025663"
Etag: "1541025663"
< Expires: Tue, 28 Aug 2018 04:13:39 GMT
Expires: Tue, 28 Aug 2018 04:13:39 GMT
< Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
< Server: ECS (lga/1318)
Server: ECS (lga/1318)
< Vary: Accept-Encoding
Vary: Accept-Encoding
< X-Cache: HIT
X-Cache: HIT
< Content-Length: 1270
Content-Length: 1270
hisco commented 6 years ago

Hi @paambaati ,

The bug was in the lib in the area that handles http1 protocol, when using http1 endpoint with a string it's internally creates an URL instance which is enumerable, therefore, the extend used was not working.

I've used the same function that nodejs http1 lib use internally to solve this. The integration tests didn't catch it because the test server answers everything I will fix it to answer only specific path as a normal real life server would do.

Thanks!