mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
Add support for http proxy (#68)
* Add support for http proxy * add test case for http proxy --------- Co-authored-by: octeep <github@bandersnatch.anonaddy.com> Co-authored-by: pufferfish <74378430+pufferffish@users.noreply.github.com>
This commit is contained in:
parent
d9c6eb7143
commit
25e6568f4d
7 changed files with 256 additions and 4 deletions
25
util.go
Normal file
25
util.go
Normal 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)),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue