mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-25 03:58:30 +00:00
SocketServer: When parsing errors from the backend, ignore ;charset=
in Content-Type headers.
This commit is contained in:
parent
35ce17e3ee
commit
5f0dc3ce6f
1 changed files with 8 additions and 1 deletions
|
@ -140,7 +140,14 @@ func (backend *backendInfo) SendRemoteCommand(remoteCommand, data string, auth A
|
||||||
if resp.StatusCode == 401 {
|
if resp.StatusCode == 401 {
|
||||||
return "", ErrAuthorizationNeeded
|
return "", ErrAuthorizationNeeded
|
||||||
} else if resp.StatusCode < 200 || resp.StatusCode > 299 { // any non-2xx
|
} else if resp.StatusCode < 200 || resp.StatusCode > 299 { // any non-2xx
|
||||||
if resp.Header.Get("Content-Type") == "application/json" {
|
// If the Content-Type header includes a charset, ignore it.
|
||||||
|
typeStr := resp.Header.Get("Content-Type")
|
||||||
|
splitIdx := strings.Index(typeStr, ";")
|
||||||
|
if ( splitIdx != -1 ) {
|
||||||
|
typeStr = strings.TrimSpace(typeStr[0:splitIdx])
|
||||||
|
}
|
||||||
|
|
||||||
|
if typeStr == "application/json" {
|
||||||
var err2 ErrForwardedFromBackend
|
var err2 ErrForwardedFromBackend
|
||||||
err := json.Unmarshal(respBytes, &err2.JSONError)
|
err := json.Unmarshal(respBytes, &err2.JSONError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue