mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 09:13:09 -06:00
Check for errors when closing response bodies
This commit is contained in:
parent
7ebb9c625d
commit
ffadf73a47
|
|
@ -348,7 +348,12 @@ func validateEmailIdentity(
|
||||||
JSON: jsonerror.Unknown("failed conecting to identity server"),
|
JSON: jsonerror.Unknown("failed conecting to identity server"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() {
|
||||||
|
err = resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).Error("validateEmailIdentity: unable to close response body")
|
||||||
|
}
|
||||||
|
}()
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 404:
|
case 404:
|
||||||
return &util.JSONResponse{
|
return &util.JSONResponse{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
"github.com/matrix-org/dendrite/setup/config"
|
"github.com/matrix-org/dendrite/setup/config"
|
||||||
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EmailAssociationRequest represents the request defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken
|
// EmailAssociationRequest represents the request defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken
|
||||||
|
|
@ -92,7 +93,12 @@ func CreateSession(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() {
|
||||||
|
err = resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).Error("CreateSession: unable to close response body")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Error if the status isn't OK
|
// Error if the status isn't OK
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
|
@ -131,7 +137,12 @@ func CheckAssociation(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", "", err
|
return false, "", "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() {
|
||||||
|
err = resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).Error("CheckAssociation: unable to close response body")
|
||||||
|
}
|
||||||
|
}()
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Medium string `json:"medium"`
|
Medium string `json:"medium"`
|
||||||
ValidatedAt int64 `json:"validated_at"`
|
ValidatedAt int64 `json:"validated_at"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue