Skip to content

Commit

Permalink
馃拕
Browse files Browse the repository at this point in the history
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
  • Loading branch information
ItalyPaleAle committed Dec 5, 2023
1 parent 161916f commit cc0092b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/http/api_directmessaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,22 @@ func (a *api) onDirectMessage(w http.ResponseWriter, r *http.Request) {
return nil, nil
})

// If there's no error, then everything is done already
if err == nil {
return
}

if resp != nil {
defer resp.Close()

// Set headers if they haven't been sent already (when success is true)
if !success.Load() {
headers := resp.Headers()
if len(headers) > 0 {
invokev1.InternalMetadataToHTTPHeader(r.Context(), headers, w.Header().Add)
}
// Set headers if present (if resp is not nil, they haven't been sent already)
headers := resp.Headers()
if len(headers) > 0 {
invokev1.InternalMetadataToHTTPHeader(r.Context(), headers, w.Header().Add)
}
}

// Handle errors
// Successful operations are already complete
// Handle errors; successful operations are already complete
var (
codeErr codeError
invokeErr invokeError
Expand All @@ -267,7 +269,7 @@ func (a *api) onDirectMessage(w http.ResponseWriter, r *http.Request) {
case errors.As(err, &invokeErr):
respondWithData(w, invokeErr.statusCode, invokeErr.msg)
return
case err != nil:
default:
respondWithError(w, messages.ErrDirectInvoke.WithFormat(targetID, err))
return
}
Expand Down

0 comments on commit cc0092b

Please sign in to comment.