mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-07-06 20:42:33 +02:00
feat: add "Host" header
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,9 @@ func FormatRawRequest(f *proxy.Flow) string {
|
|||||||
r := f.Request
|
r := f.Request
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
fmt.Fprintf(&sb, "%s %s %s\n", r.Method, r.URL.RequestURI(), r.Proto)
|
fmt.Fprintf(&sb, "%s %s %s\n", r.Method, r.URL.RequestURI(), r.Proto)
|
||||||
|
if r.URL.Host != "" {
|
||||||
|
fmt.Fprintf(&sb, "Host: %s\n", r.URL.Host)
|
||||||
|
}
|
||||||
for _, line := range util.SortedHeaderLines(r.Header) {
|
for _, line := range util.SortedHeaderLines(r.Header) {
|
||||||
sb.WriteString(line)
|
sb.WriteString(line)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,14 @@ func parseRawRequest(content string, req *intercept.PendingRequest) {
|
|||||||
if parsed.Proto != "" {
|
if parsed.Proto != "" {
|
||||||
r.Proto = parsed.Proto
|
r.Proto = parsed.Proto
|
||||||
}
|
}
|
||||||
|
if parsed.Host != "" {
|
||||||
|
r.URL.Host = parsed.Host
|
||||||
|
}
|
||||||
r.Header = make(http.Header)
|
r.Header = make(http.Header)
|
||||||
for _, h := range parsed.Headers {
|
for _, h := range parsed.Headers {
|
||||||
|
if strings.EqualFold(h.Key, "host") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
r.Header.Set(h.Key, h.Value)
|
r.Header.Set(h.Key, h.Value)
|
||||||
}
|
}
|
||||||
if parsed.Body != "" {
|
if parsed.Body != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user