Expand documentation of WebSocketHandler.check_origin.

Document the potential problems that arise with websockets and
self-signed certificates.
Merge branch 'branch4.0'
Implement permessage-deflate websocket extension.

Parameters to the extension are not fully supported (the client side
supports client_no_context_takeover which is mandatory to implement,
but the server rejects any parameters offered by the client, and neither
side supports setting wbits).

Closes #308.
Closes #668.
Support the max_wbits websocket deflate parameters.

Slightly improve error handling in the websocket handshake.