Skip to content

Commit

Permalink
Fix proxy server request header
Browse files Browse the repository at this point in the history
  • Loading branch information
HeHang0 committed Mar 18, 2024
1 parent b6e959e commit 1bf0032
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions proxy-server/proxy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func ProxyHandler(writer http.ResponseWriter, request *http.Request) {
}
if strings.HasPrefix(queryUrl, "http") {
requestData = &RequestData{Url: queryUrl}
requestData.Headers = map[string]string{}
for key, value := range request.Header {
requestData.Headers[key] = strings.Join(value, ",")
}
} else {
body := make([]byte, request.ContentLength)
_, _ = request.Body.Read(body)
Expand Down Expand Up @@ -84,7 +88,6 @@ func setRequestHeaders(request *http.Request, headers map[string]string) {
case "accept":
request.Header.Set("Accept", value)
case "host":
case "range":
default:
request.Header.Set(key, value)
}
Expand All @@ -107,9 +110,7 @@ func setResponseHeaders(response http.ResponseWriter, headers http.Header) {
case "accesscontrolexposeheaders":
case "accesscontrolallowcredentials":
default:
if len(value) > 0 {
response.Header().Set(key, value[0])
}
response.Header().Set(key, strings.Join(value, ", "))
}
}
}
Expand Down

0 comments on commit 1bf0032

Please sign in to comment.