mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-09-16 09:09:37 +02:00
Merge pull request #772 from AnthonyMichaelTDM/issue-771
fix(issue 771): panics when rewriting headers for websockets, and strange issue with logging across a month boundary
This commit is contained in:
@@ -75,5 +75,9 @@ func SplitUpDownStreamHeaders(rewriteOptions *HeaderRewriteOptions) ([][]string,
|
||||
downstreamHeaderCounter++
|
||||
}
|
||||
|
||||
// Slice the arrays to only include the filled portions to prevent nil slice access
|
||||
upstreamHeaders = upstreamHeaders[:upstreamHeaderCounter]
|
||||
downstreamHeaders = downstreamHeaders[:downstreamHeaderCounter]
|
||||
|
||||
return upstreamHeaders, downstreamHeaders
|
||||
}
|
||||
|
@@ -211,6 +211,10 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
UserDefinedHeaders: rewrittenUserDefinedHeaders,
|
||||
})
|
||||
for _, headerValuePair := range upstreamHeaders {
|
||||
//Skip empty header pairs
|
||||
if len(headerValuePair) < 2 {
|
||||
continue
|
||||
}
|
||||
//Do not copy Upgrade and Connection headers, it will be handled by the upgrader
|
||||
if strings.EqualFold(headerValuePair[0], "Upgrade") || strings.EqualFold(headerValuePair[0], "Connection") {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user