Add support for http proxy

This commit is contained in:
Wayback Archiver 2023-05-20 14:59:12 +01:00
parent 6fcd53d2a0
commit 0b18a00fcb
No known key found for this signature in database
GPG key ID: 57D14486138C9377
5 changed files with 239 additions and 3 deletions

25
util.go Normal file
View file

@ -0,0 +1,25 @@
package wireproxy
import (
"bytes"
"io"
"net/http"
"strconv"
)
const space = " "
func responseWith(req *http.Request, statusCode int) *http.Response {
statusText := http.StatusText(statusCode)
body := "wireproxy:" + space + req.Proto + space + strconv.Itoa(statusCode) + space + statusText + "\r\n"
return &http.Response{
StatusCode: statusCode,
Status: statusText,
Proto: req.Proto,
ProtoMajor: req.ProtoMajor,
ProtoMinor: req.ProtoMinor,
Header: http.Header{},
Body: io.NopCloser(bytes.NewBufferString(body)),
}
}