Skip to content

Set a timeout on the HTTP Protocol sniffer #11

@RoganDawes

Description

@RoganDawes

If the protocol does not involve the client speaking first, the HTTP protocol sniffer will prevent progress, as it waits for enough characters to detect whether the protocol is in fact HTTP.
If there is a timeout on the handler, set when the handler is added to the channel, when the timeout fires it can be assumed that the protocol is not actually HTTP.
Note: This will fail to detect manually typed HTTP requests, unless the timeout is made large enough to allow the request to be typed out before the timeout fires. Making it too large, however, can negatively affect performance of the non-HTTP protocol. It would appear to be reasonable to use a short timeout (e.g. 1 second), because most browsers will send the request as soon as the connection is opened. It can be worked around for the manual case by using e.g. printf, etc.

See handler/src/main/java/io/netty/handler/timeout/IdleStateHandler.java for an example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions