2
0
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:
ymmt2005 2016-03-09 23:23:35 +09:00
parent 4d0b2534e4
commit 322a89746a
2 changed files with 7 additions and 5 deletions

View File

@ -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,

View File

@ -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)
}