refact: session/modules -> modules

This commit is contained in:
evilsocket 2018-01-08 09:28:46 +01:00
parent da10147b7c
commit 64221a126d
13 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,51 @@
package modules
import (
"fmt"
"io/ioutil"
"net/http"
)
type JSHeader struct {
Name string
Value string
}
type JSRequest struct {
Method string
Version string
Path string
Hostname string
Headers []JSHeader
Body string
req *http.Request
}
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,
req: req,
}
}
func (j *JSRequest) ReadBody() string {
raw, err := ioutil.ReadAll(j.req.Body)
if err != nil {
return ""
}
j.Body = string(raw)
return j.Body
}