mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 21:12:05 -07:00
fix: setting other fields in marshaled js http request
This commit is contained in:
parent
e8c6c7cf92
commit
9f8aa21136
2 changed files with 26 additions and 13 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type JSHeader struct {
|
||||
|
@ -12,30 +13,41 @@ type JSHeader struct {
|
|||
}
|
||||
|
||||
type JSRequest struct {
|
||||
Method string
|
||||
Version string
|
||||
Path string
|
||||
Hostname string
|
||||
Headers []JSHeader
|
||||
Body string
|
||||
req *http.Request
|
||||
Client string
|
||||
Method string
|
||||
Version string
|
||||
Path string
|
||||
Hostname string
|
||||
ContentType string
|
||||
Headers []JSHeader
|
||||
Body string
|
||||
req *http.Request
|
||||
}
|
||||
|
||||
func NewJSRequest(req *http.Request) JSRequest {
|
||||
headers := make([]JSHeader, 0)
|
||||
cType := ""
|
||||
|
||||
for key, values := range req.Header {
|
||||
for _, value := range values {
|
||||
headers = append(headers, JSHeader{key, value})
|
||||
|
||||
if key == "Content-Type" {
|
||||
cType = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JSRequest{
|
||||
Method: req.Method,
|
||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||
Path: req.URL.Path,
|
||||
Hostname: req.Host,
|
||||
Headers: headers,
|
||||
req: req,
|
||||
Client: strings.Split(req.RemoteAddr, ":")[0],
|
||||
Method: req.Method,
|
||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||
Path: req.URL.Path,
|
||||
Hostname: req.Host,
|
||||
ContentType: cType,
|
||||
Headers: headers,
|
||||
|
||||
req: req,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue