mirror of
https://github.com/bettercap/bettercap
synced 2025-07-08 05:51:37 -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
|
@ -7,6 +7,7 @@ const (
|
||||||
|
|
||||||
RED = "\033[31m"
|
RED = "\033[31m"
|
||||||
GREEN = "\033[32m"
|
GREEN = "\033[32m"
|
||||||
|
BLUE = "\033[34m"
|
||||||
YELLOW = "\033[33m"
|
YELLOW = "\033[33m"
|
||||||
|
|
||||||
FG_BLACK = "\033[30m"
|
FG_BLACK = "\033[30m"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JSHeader struct {
|
type JSHeader struct {
|
||||||
|
@ -12,10 +13,12 @@ type JSHeader struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type JSRequest struct {
|
type JSRequest struct {
|
||||||
|
Client string
|
||||||
Method string
|
Method string
|
||||||
Version string
|
Version string
|
||||||
Path string
|
Path string
|
||||||
Hostname string
|
Hostname string
|
||||||
|
ContentType string
|
||||||
Headers []JSHeader
|
Headers []JSHeader
|
||||||
Body string
|
Body string
|
||||||
req *http.Request
|
req *http.Request
|
||||||
|
@ -23,18 +26,27 @@ type JSRequest struct {
|
||||||
|
|
||||||
func NewJSRequest(req *http.Request) JSRequest {
|
func NewJSRequest(req *http.Request) JSRequest {
|
||||||
headers := make([]JSHeader, 0)
|
headers := make([]JSHeader, 0)
|
||||||
|
cType := ""
|
||||||
|
|
||||||
for key, values := range req.Header {
|
for key, values := range req.Header {
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
headers = append(headers, JSHeader{key, value})
|
headers = append(headers, JSHeader{key, value})
|
||||||
|
|
||||||
|
if key == "Content-Type" {
|
||||||
|
cType = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSRequest{
|
return JSRequest{
|
||||||
|
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),
|
||||||
Path: req.URL.Path,
|
Path: req.URL.Path,
|
||||||
Hostname: req.Host,
|
Hostname: req.Host,
|
||||||
|
ContentType: cType,
|
||||||
Headers: headers,
|
Headers: headers,
|
||||||
|
|
||||||
req: req,
|
req: req,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue