Skip to content

RequestHandler::onRequest not called #592

@chriselving

Description

@chriselving

The comments in RequestHandler.h indicate that onRequest will be invoked for all handlers and that onError will never be invoked prior to onRequest:

  /**
   * Invoked when we have successfully fetched headers from client. This will
   * always be the first callback invoked on your handler.
   */
  virtual void onRequest(std::unique_ptr<HTTPMessage> headers) noexcept = 0;
  /**
   * Request failed. Maybe because of read/write error on socket or client
   * not being able to send request in time.
   *
   * NOTE: Can be invoked at any time (except for before onRequest).
   *
   * No more callbacks will be invoked after this. You should clean up after
   * yourself.
   */
  virtual void onError(ProxygenError err) noexcept = 0;

These comments do not match the implementation. For example, when a request contains an Expect: foo header (where foo is anything other than 100-continue), RequestHandlerAdaptor will invoke onError and detach the handler without having invoked onRequest.

There are a lot of conditions between HTTPServerAcceptor::newHandler creating a handler and the session invoking onRequest, and the set of conditions varies depending on the underlying session type, so it's not obvious whether there are other scenarios that also violate the contract.

Is this a defect in the implementation or the comments?

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