luasecでluaを使用して、https経由でWebサーバーからページを取得しようとしています。ほとんどのページで私のスクリプトは意図どおりに機能しますが、ressourceに特殊文字(「é」など)が含まれていると、301個の応答をループに送り込まれています。なぜWebサーバーは301と要求された正確な場所で返答しますか?
このコードは私のジレンマ(無実を保護するために編集さ実際のサーバの詳細)を示すsnipletてみましょう:1を取得することができるかもしれない方法逆説
HTTP/1.1 301 Moved Permanently - GET was for "https://www.example.com/S%C3%A9ance" headers are { ["content-type"]="text/html; charset=UTF-8";["set-cookie"]="PHPSESSID=e80oo5dkouh8gh0ruit7mj28t6; path=/";["content-length"]="0";["connection"]="close";["date"]="Wed, 15 Mar 2017 19:31:24 GMT";["location"]="S%C3%A9ance";} body is "" equal HTTP/1.1 301 Moved Permanently - GET was for "https://www.example.com/S%C3%A9ance"
になり
local https = require "ssl.https"
local prefix = "https://www.example.com"
local suffix = "/S%C3%A9ance"
local body,code,headers,status = https.request(prefix .. suffix)
print(status .. " - GET was for \"" .. prefix .. suffix .. "\"")
print("headers are " .. myTostring(headers))
print("body is " .. myTostring(body))
if suffix == headers.location then
print("equal")
else
print("not equal")
end
local body,code,headers,status = https.request(prefix .. headers.location)
print(status .. " - GET was for \"" .. prefix .. suffix .. "\"")
見つからないページは、luaを使用し、できるだけ追加の依存関係を使用しますか?