Rename resp lol

This commit is contained in:
Melon 2023-10-30 00:16:48 +00:00
parent 1a6d416b03
commit 852fc9b872
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -2,12 +2,10 @@ package main
import ( import (
"flag" "flag"
"io"
"log" "log"
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
"strings"
"time" "time"
) )
@ -32,24 +30,23 @@ func main() {
if hostFlag != "" { if hostFlag != "" {
r.Out.Host = hostFlag r.Out.Host = hostFlag
} }
r.Out.Header = r.In.Header.Clone()
}, },
ModifyResponse: func(response *http.Response) error { ModifyResponse: func(resp *http.Response) error {
if !allowCors { if !allowCors {
return nil return nil
} }
response.Header.Add("Access-Control-Allow-Origin", "*") resp.Header.Set("Access-Control-Allow-Origin", "*")
response.Header.Add("Access-Control-Allow-Credentials", "true") resp.Header.Set("Access-Control-Allow-Credentials", "true")
response.Header.Add("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") resp.Header.Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
response.Header.Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") resp.Header.Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
if response.Request.Method == "OPTIONS" { if resp.Request.Method == http.MethodOptions {
_ = response.Body.Close() resp.Header.Set("Content-Type", "text/plain; charset=utf-8")
response.Header.Set("Content-Type", "text/plain; charset=utf-8") resp.Header.Set("X-Content-Type-Options", "nosniff")
response.Header.Set("X-Content-Type-Options", "nosniff") resp.StatusCode = http.StatusNoContent
response.StatusCode = http.StatusNoContent resp.Status = http.StatusText(http.StatusNoContent)
response.Status = http.StatusText(http.StatusNoContent)
response.Body = io.NopCloser(strings.NewReader("No Content\n"))
} }
return nil return nil
}, },