This commit is contained in:
2025-10-19 13:28:13 +07:00
12 changed files with 149 additions and 98 deletions
+7 -18
View File
@@ -1,12 +1,7 @@
package http
import (
"strings"
)
var (
CRLF = []byte("\r\n")
SP = []byte(" ")
"git.3crabs.ru/VLADIMIR/net/url"
)
type Client struct {
@@ -14,22 +9,16 @@ type Client struct {
Transport RoundTripper
}
func (c *Client) Do(method string, url string, headers []Header) (*Response, error) {
url = strings.TrimPrefix(url, "http://")
url = strings.TrimPrefix(url, "https://")
path := "/"
arr := strings.Split(url, "/")
if len(arr) == 2 {
path = arr[1]
}
if !strings.HasPrefix(path, "/") {
path = "/" + path
func (c *Client) Do(method string, rawURl string, headers []Header) (*Response, error) {
u, err := url.Parse(rawURl)
if err != nil {
return nil, err
}
connectPath := ""
if c.DNS != nil {
var err error
connectPath, err = c.DNS.GetIP(arr[0])
connectPath, err = c.DNS.GetIP(u.Host)
if err != nil {
return nil, err
}
@@ -39,7 +28,7 @@ func (c *Client) Do(method string, url string, headers []Header) (*Response, err
&Request{
ConnectPath: connectPath,
Method: method,
Path: path,
URL: u,
Protocol: "HTTP/1.0",
Headers: headers,
},