vincenthz/hs-tls — pull request #7 by kolmodin (2012-02-16 08:35:41+00:00)
Title: Client code for NPN

Hi Vincent,

I added client side code for NPN, together with a simple roundtrip test.

Considerations;
- Only positive test, does not test that server/client reacts appropriately if either party doesn't follow the spec.
- Should add more tests to test failure discovery too. And in a cleaner way, this was copy/paste :)
- No tests for how NPN works with session reusage. Probably doesn't work yet.
- In the client, storing the suggestions made in ServerHello in the state (stServerNextProtocolSuggest :: Maybe [B.ByteString]) which is later used in sendChangeCipherAndFinish. After this one time usage, there is no need for these values, but I couldn't find an easy way without using the state.
- Names exposed to the user are confusing, not easy to spot which part belongs to server/client. You can guess it by the types, but I wish the names where more clear. See;

, onSuggestNextProtocols :: IO (Maybe [B.ByteString])
, onNPNServerSuggest :: Maybe ([B.ByteString] -> IO B.ByteString)

maybe change to;
onServerSuggestNextProtocols -- server should suggest
onClientChooseNextProtocol -- client should reply

Regards,
Lennart