@@ -12,6 +12,8 @@ import (
1212 "os"
1313 "strings"
1414 "time"
15+
16+ "github.com/slicingmelon/go-rawurlparser"
1517)
1618
1719// parseFile reads a file given its filename and returns a list containing each of its lines.
@@ -46,7 +48,6 @@ type header struct {
4648}
4749
4850// request makes an HTTP request using headers `headers` and proxy `proxy`.
49- //
5051// If `method` is empty, it defaults to "GET".
5152func request (method , uri string , headers []header , proxy * url.URL , rateLimit bool , timeout int , redirect bool ) (int , []byte , error ) {
5253 if method == "" {
@@ -57,21 +58,23 @@ func request(method, uri string, headers []header, proxy *url.URL, rateLimit boo
5758 proxy = nil
5859 }
5960
60- client := & http.Client {
61- Transport : & http.Transport {
62- Proxy : http .ProxyURL (proxy ),
63- TLSClientConfig : & tls.Config {
64- InsecureSkipVerify : true ,
65- },
66- DialContext : (& net.Dialer {
67- Timeout : time .Duration (timeout ) / 1000 * time .Second ,
68- KeepAlive : 30 * time .Second ,
69- }).DialContext ,
70- MaxIdleConns : 100 ,
71- IdleConnTimeout : 90 * time .Second ,
72- TLSHandshakeTimeout : 10 * time .Second ,
73- ExpectContinueTimeout : 1 * time .Second ,
61+ customTransport := & http.Transport {
62+ Proxy : http .ProxyURL (proxy ),
63+ TLSClientConfig : & tls.Config {
64+ InsecureSkipVerify : true ,
7465 },
66+ DialContext : (& net.Dialer {
67+ Timeout : time .Duration (timeout ) / 1000 * time .Second ,
68+ KeepAlive : 30 * time .Second ,
69+ }).DialContext ,
70+ MaxIdleConns : 100 ,
71+ IdleConnTimeout : 90 * time .Second ,
72+ TLSHandshakeTimeout : 10 * time .Second ,
73+ ExpectContinueTimeout : 1 * time .Second ,
74+ }
75+
76+ client := & http.Client {
77+ Transport : customTransport ,
7578 }
7679
7780 if ! redirect {
@@ -80,11 +83,30 @@ func request(method, uri string, headers []header, proxy *url.URL, rateLimit boo
8083 }
8184 }
8285
83- req , err := http .NewRequest (method , uri , nil )
84- if err != nil {
85- return 0 , nil , nil
86- }
87- req .Close = true
86+ // Use raw URL parser instead
87+ parsedURL := rawurlparser .RawURLParse (uri )
88+
89+ // Create new request
90+ req := & http.Request {
91+ Method : method ,
92+ URL : & url.URL {
93+ Scheme : parsedURL .Scheme ,
94+ Host : parsedURL .Host ,
95+ Opaque : parsedURL .Path , // Use Opaque to prevent path normalization
96+ },
97+ Header : make (http.Header ),
98+ Close : true ,
99+ }
100+
101+ //log.Printf("Debug - Raw URL parsed: %s", uri)
102+ // Don't use URL.String() for debugging, as it will perform encodings and normalization
103+ // log.Printf("Debug - Request Components - Scheme: %s, Host: %s, Path: %s, RawPath: %s, Opaque: %s",
104+ // req.URL.Scheme,
105+ // req.URL.Host,
106+ // req.URL.Path,
107+ // req.URL.RawPath,
108+ // req.URL.Opaque,
109+ // )
88110
89111 for _ , header := range headers {
90112 req .Header .Add (header .key , header .value )
0 commit comments