Skip to content

http request fails when $http_proxy contains trailing slash #108

@mischief

Description

@mischief

hi, my $http_proxy is set to http://127.0.0.1:8118/. this works fine with all other programs (chromium, curl, ...). http.request asserts when the trailing slash is present. here's a patch to fix it.

diff --git a/http/request.lua b/http/request.lua
index 3f12a8f..ce1cb88 100644
--- a/http/request.lua
+++ b/http/request.lua
@@ -59,7 +59,7 @@ local function new_from_uri(uri_t, headers)
 		is_connect = headers:get(":method") == "CONNECT"
 	end
 	if is_connect then
-		assert(uri_t.path == nil or uri_t.path == "", "CONNECT requests cannot have a path")
+		assert(uri_t.path == nil or uri_t.path == "" or uri_t.path == "/", "CONNECT requests cannot have a path")
 		assert(uri_t.query == nil, "CONNECT requests cannot have a query")
 		assert(headers:has(":authority"), ":authority required for CONNECT requests")
 	else

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions