mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
Enable reading/writing of request scheme in HTTP proxy
This commit is contained in:
parent
1c474c85d2
commit
1999665429
1 changed files with 4 additions and 2 deletions
|
@ -18,6 +18,7 @@ type JSRequest struct {
|
||||||
Client string
|
Client string
|
||||||
Method string
|
Method string
|
||||||
Version string
|
Version string
|
||||||
|
Scheme string
|
||||||
Path string
|
Path string
|
||||||
Query string
|
Query string
|
||||||
Hostname string
|
Hostname string
|
||||||
|
@ -48,6 +49,7 @@ func NewJSRequest(req *http.Request) *JSRequest {
|
||||||
Client: strings.Split(req.RemoteAddr, ":")[0],
|
Client: strings.Split(req.RemoteAddr, ":")[0],
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||||
|
Scheme: req.URL.Scheme
|
||||||
Hostname: req.Host,
|
Hostname: req.Host,
|
||||||
Path: req.URL.Path,
|
Path: req.URL.Path,
|
||||||
Query: req.URL.RawQuery,
|
Query: req.URL.RawQuery,
|
||||||
|
@ -63,7 +65,7 @@ func NewJSRequest(req *http.Request) *JSRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JSRequest) NewHash() string {
|
func (j *JSRequest) NewHash() string {
|
||||||
hash := fmt.Sprintf("%s.%s.%s.%s.%s.%s.%s", j.Client, j.Method, j.Version, j.Hostname, j.Path, j.Query, j.ContentType)
|
hash := fmt.Sprintf("%s.%s.%s.%s.%s.%s.%s.%s", j.Client, j.Method, j.Version, j.Scheme, j.Hostname, j.Path, j.Query, j.ContentType)
|
||||||
for _, h := range j.Headers {
|
for _, h := range j.Headers {
|
||||||
hash += fmt.Sprintf(".%s-%s", h.Name, h.Value)
|
hash += fmt.Sprintf(".%s-%s", h.Name, h.Value)
|
||||||
}
|
}
|
||||||
|
@ -152,7 +154,7 @@ func (j *JSRequest) ParseForm() map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JSRequest) ToRequest() (req *http.Request) {
|
func (j *JSRequest) ToRequest() (req *http.Request) {
|
||||||
url := fmt.Sprintf("%s://%s:%s%s?%s", j.req.URL.Scheme, j.Hostname, j.req.URL.Port(), j.Path, j.Query)
|
url := fmt.Sprintf("%s://%s:%s%s?%s", j.Scheme, j.Hostname, j.req.URL.Port(), j.Path, j.Query)
|
||||||
if j.Body == "" {
|
if j.Body == "" {
|
||||||
req, _ = http.NewRequest(j.Method, url, j.req.Body)
|
req, _ = http.NewRequest(j.Method, url, j.req.Body)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue