twitter/finagle — pull request #266 by mmollaverdi (2014-05-03 08:03:49+00:00)
Title: ExceptionFilter does not set the response content-length to 0

[finagle-http] ExceptionFilter does not set the response content-length to 0

Problem

The com.twitter.finagle.http.filter.ExceptionFilter class in finagle-http module calls response.clearContent() to return an empty response but does not set the content-length header to 0.

AWS load balancers are sensitive to missing content-length headers and translate such responses to 502s (Bad gateway).

Solution

Content-Length header is set to 0 in ExceptionFilter class for both 499 and 500 responses.

Results

Content-length is correctly set on empty responses returned by ExceptionFilter.