1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00

SocketServer: When parsing errors from the backend, ignore ;charset= in Content-Type headers.

This commit is contained in:
SirStendec 2017-09-17 14:22:31 -04:00
parent 35ce17e3ee
commit 5f0dc3ce6f

View file

@ -140,7 +140,14 @@ func (backend *backendInfo) SendRemoteCommand(remoteCommand, data string, auth A
if resp.StatusCode == 401 {
return "", ErrAuthorizationNeeded
} 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
err := json.Unmarshal(respBytes, &err2.JSONError)
if err != nil {