-
Notifications
You must be signed in to change notification settings - Fork 1
/
https.go
29 lines (23 loc) · 811 Bytes
/
https.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"errors"
"fmt"
"net/http"
)
const ConnectionEstablished = "HTTP/1.0 200 Connection established\r\n\r\n"
type httpsProxy struct{}
func (hp *httpsProxy) SetupOutgoing(connection *connection, request *http.Request) error {
// Create our outgoing connection.
outgoingHost := request.URL.Host
outgoingConn, err := connection.Dial("tcp", outgoingHost)
if err != nil {
return errors.New(fmt.Sprint("Error opening outgoing connection to", outgoingHost, err))
}
connection.outgoing = outgoingConn
// Signal to the incoming connection that the outgoing connection was established.
_, err = connection.incoming.Write([]byte(ConnectionEstablished))
if err != nil {
return errors.New(fmt.Sprint("Could not send Continue response to incoming", outgoingHost, err))
}
return nil
}