wajam/nlb — pull request #24 by clementgarnier (2013-11-01 21:59:59+00:00)
Title: Fix becomeAvailable() race + add HTTP 1.0 support

Two bugs that made our benchmarks randomly fail:

1. in `ClientActor`, we were forwarding the response before going back to the `waitForRequest` state, which possibly caused a race.

`SprayUtils` has been refactored, simplified, and headers sanitization is now made via an explicit function call to either `prepareRequest()` or `prepareResponse()` instead of a combined partial function in Actors' behaviours.

The `prepareRequest()` function actually handles more than header cleanup it also sets the proper `Host` header and the proper (relative) uri.

2. in `ForwarderActor`, we were checking the `Connection` header after the response had been sanitized, thus we were never taking a `Connection: close` into account and were pooling connections that were closed straight after.

There is now a clear separation between the prepared response and the response coming from the endpoint, against which the header is matched. The header is also saved on the request and retrieved on the response sent to the client, to make sure that both client and server agree on keeping it alive or not.