Skip to content

Commit

Permalink
Merge pull request #962 from WhoSoup/factomize-reverse_badrequest
Browse files Browse the repository at this point in the history
Reversing API status code
  • Loading branch information
carryforward authored Feb 4, 2020
2 parents c0f29f1 + acc9984 commit 3e1691b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wsapi/debugapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func HandleDebug(writer http.ResponseWriter, request *http.Request) {
state, err := GetState(request)
if err != nil {
wsDebugLog.Errorf("failed to extract port from request: %s", err)
writer.WriteHeader(http.StatusOK)
writer.WriteHeader(http.StatusBadRequest)
return
}

Expand Down
2 changes: 1 addition & 1 deletion wsapi/wsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func returnV1Msg(writer http.ResponseWriter, msg string, success bool) {
}

func handleV1Error(writer http.ResponseWriter, err *primitives.JSONError) {
writer.WriteHeader(http.StatusOK)
writer.WriteHeader(http.StatusBadRequest)
return
}

Expand Down
2 changes: 1 addition & 1 deletion wsapi/wsapiV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func checkHttpPasswordOkV1(writer http.ResponseWriter, request *http.Request) bo
}
} else {
wsLog.Errorf("failed to get state from request: %s", err)
writer.WriteHeader(http.StatusOK)
writer.WriteHeader(http.StatusBadRequest)
return false
}
return true
Expand Down
4 changes: 2 additions & 2 deletions wsapi/wsapiV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func HandleV2(writer http.ResponseWriter, request *http.Request) {
state, err := GetState(request)
if err != nil {
wsLog.Errorf("failed to extract port from request: %s", err)
writer.WriteHeader(http.StatusOK)
writer.WriteHeader(http.StatusBadRequest)
return
}

Expand Down Expand Up @@ -520,7 +520,7 @@ func HandleV2Error(writer http.ResponseWriter, j *primitives.JSON2Request, jErr
}
resp.Error = jErr

writer.WriteHeader(http.StatusOK)
writer.WriteHeader(http.StatusBadRequest)
_, err := writer.Write([]byte(resp.String()))
if err != nil {
wsLog.Errorf("failed to write error response: %v", err)
Expand Down

0 comments on commit 3e1691b

Please sign in to comment.