mirror of
https://github.com/stefan01/transocks.git
synced 2025-02-22 03:30:45 +07:00
[http_tunnel] trim rough edges.
This commit is contained in:
parent
4d0b2534e4
commit
322a89746a
@ -33,15 +33,15 @@ type httpDialer struct {
|
||||
}
|
||||
|
||||
func httpDialType(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error) {
|
||||
authz := ""
|
||||
var header http.Header
|
||||
if uu := u.User; uu != nil {
|
||||
passwd, _ := uu.Password()
|
||||
up := uu.Username() + ":" + passwd
|
||||
authz = "Basic " + base64.StdEncoding.EncodeToString([]byte(up))
|
||||
}
|
||||
header := map[string][]string{
|
||||
authz := "Basic " + base64.StdEncoding.EncodeToString([]byte(up))
|
||||
header = map[string][]string{
|
||||
"Proxy-Authorization": []string{authz},
|
||||
}
|
||||
}
|
||||
return &httpDialer{
|
||||
addr: u.Host,
|
||||
header: header,
|
||||
|
@ -23,6 +23,8 @@ func TestHTTPDialer(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
conn.Write([]byte("GET / HTTP/1.1\r\nHost: www.yahoo.com:80\r\nConnection: close\r\n\r\n"))
|
||||
io.Copy(os.Stdout, conn)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user