daurnimator / lua-http

HTTP Library for Lua. Supports HTTP(S) 1.0, 1.1 and 2.0; client and server.
https://daurnimator.github.io/lua-http/
MIT License
778 stars 80 forks source link

http.request..new_from_uri(url):go() 301 redirect, processing stops and no response is returned #189

Open ghost opened 3 years ago

ghost commented 3 years ago

@daurnimator

http ver 0.4

local request = require "http.request"

local headers, stream = request.new_from_uri('https://kotobank.jp/word/%25E3%2583%2596%25E3%2583%25A9%25E3%2583%2583%25E3%2583%2589%25E3%2583%25AA%25E3%2583%25BC%2528James+Bradley%2529-1588121'):go()

You will not proceed to the next step in the process.

$ curl -v https://kotobank.jp/word/%25E3%2583%2596%25E3%2583%25A9%25E3%2583%2583%25E3%2583%2589%25E3%2583%25AA%25E3%2583%25BC%2528James+Bradley%2529-1588121
*   Trying 54.230.147.82...
* TCP_NODELAY set
* Connected to kotobank.jp (54.230.147.82) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=JP; ST=Tokyo; L=Shibuya-ku; O=VOYAGE MARKETING, Inc.; CN=*.kotobank.jp
*  start date: Feb 26 00:00:00 2021 GMT
*  expire date: Mar 14 23:59:59 2022 GMT
*  subjectAltName: host "kotobank.jp" matched cert's "kotobank.jp"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f831680fc00)
> GET /word/%25E3%2583%2596%25E3%2583%25A9%25E3%2583%2583%25E3%2583%2589%25E3%2583%25AA%25E3%2583%25BC%2528James+Bradley%2529-1588121 HTTP/2
> Host: kotobank.jp
> User-Agent: curl/7.64.1
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 301
< content-type: text/html; charset=UTF-8
< content-length: 0
< date: Thu, 03 Jun 2021 10:05:59 GMT
< server: Apache
< location: /word/%E3%83%96%E3%83%A9%E3%83%83%E3%83%89%E3%83%AA%E3%83%BC%28James%20Bradley%29-1588121
< cache-control: max-age=60
< expires: Thu, 03 Jun 2021 10:06:59 GMT
< x-cache: Hit from cloudfront
< via: 1.1 912c702e8ae221d9e34208a70f672677.cloudfront.net (CloudFront)
< x-amz-cf-pop: KIX56-C1
< x-amz-cf-id: neXdLZ18aIAfP_5ubUYLZYjxgD0ovGueF8b7ee4OTAad2xATG2PsBQ==
< age: 12
<
* Connection #0 to host kotobank.jp left intact
* Closing connection 0

It looks like the process stops when redirecting 301.

daurnimator commented 3 years ago

Seems to be getting in an EPIPE loop... interesting+odd.