mirror of
https://github.com/bettercap/bettercap
synced 2025-07-11 15:46:59 -07:00
perf: precompiling proxy script callbacks
This commit is contained in:
parent
8f22e4a30c
commit
b0ee042229
3 changed files with 88 additions and 62 deletions
|
@ -1,5 +1,10 @@
|
|||
package session_modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type JSHeader struct {
|
||||
Name string
|
||||
Value string
|
||||
|
@ -14,6 +19,23 @@ type JSRequest struct {
|
|||
Body string
|
||||
}
|
||||
|
||||
func NewJSRequest(req *http.Request) JSRequest {
|
||||
headers := make([]JSHeader, 0)
|
||||
for key, values := range req.Header {
|
||||
for _, value := range values {
|
||||
headers = append(headers, JSHeader{key, value})
|
||||
}
|
||||
}
|
||||
|
||||
return JSRequest{
|
||||
Method: req.Method,
|
||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||
Path: req.URL.Path,
|
||||
Hostname: req.Host,
|
||||
Headers: headers,
|
||||
}
|
||||
}
|
||||
|
||||
func (j *JSRequest) ReadBody() string {
|
||||
return "TODO: read body"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue