Skip to content

Commit

Permalink
Use the appropriate HTTP response code for backend timeouts (#1313)
Browse files Browse the repository at this point in the history
Upon timeout or cancellation of a backend connection context, CTFE currently returns HTTP 408 to the client.  This seems wrong, because 408 is intended to mean that the client did not send its request quickly enough.

[HTTP 504](https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5) (Gateway Timeout) seems a more appropriate error code, given that the timeout or cancellation occurred because an "upstream server" (i.e., the Trillian backend) did not respond quickly enough:

>  The 504 (Gateway Timeout) status code indicates that the server,
>   while acting as a gateway or proxy, did not receive a timely response
>   from an upstream server it needed to access in order to complete the
>   request.
  • Loading branch information
robstradling committed Jan 17, 2024
1 parent 726c8de commit c83d4d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

* Add build tags for AIX operating system

### Misc

* Return HTTP 504 instead of HTTP 408 upon timeout or cancellation of a backend connection context by @robstradling in https://github.com/google/certificate-transparency-go/pull/1313

## v1.1.7

* Recommended Go version for development: 1.20
Expand Down
2 changes: 1 addition & 1 deletion trillian/ctfe/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ func (li *logInfo) toHTTPStatus(err error) int {
case codes.OK:
return http.StatusOK
case codes.Canceled, codes.DeadlineExceeded:
return http.StatusRequestTimeout
return http.StatusGatewayTimeout
case codes.InvalidArgument, codes.OutOfRange, codes.AlreadyExists:
return http.StatusBadRequest
case codes.NotFound:
Expand Down

0 comments on commit c83d4d3

Please sign in to comment.