### Method

# Soup Server add_early_handler

#### Declaration [src]

    void
    soup_server_add_early_handler (
      SoupServer* server,
      const char* path,
      SoupServerCallback callback,
      gpointer user_data,
      GDestroyNotify destroy
    )

#### Description [src]

Adds an “early” handler to `server` for requests prefixed by `path`.

Note that “normal” and “early” handlers are matched up together, so if you add a normal handler for “/foo” and an early handler for “/foo/bar”, then a request to “/foo/bar” (or any path below it) will run only the early handler. (But if you add both handlers at the same path, then both will get run.)

For requests under `path` (that have not already been assigned a status code by a `SoupAuthDomain` or a signal handler), `callback` will be invoked after receiving the request headers, but before receiving the request body; the message’s method and request-headers properties will be set.

Early handlers are generally used for processing requests with request bodies in a streaming fashion. If you determine that the request will contain a message body, normally you would call `soup_message_body_set_accumulate()` on the message’s request-body to turn off request-body accumulation, and connect to the message’s `SoupServerMessage::got-chunk` signal to process each chunk as it comes in.

To complete the message processing after the full message body has been read, you can either also connect to `SoupServerMessage::got-body`, or else you can register a non-early handler for `path` as well. As long as you have not set the status-code by the time `SoupServerMessage::got-body` is emitted, the non-early handler will be run as well.

#### Parameters

`path`

  Type: `const char*`

  The toplevel path for the handler.

  The argument can be `NULL`.
  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`callback`

  Type: `SoupServerCallback`

  Callback to invoke for requests under `path`.

`user_data`

  Type: `gpointer`

  Data for `callback`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`destroy`

  Type: `GDestroyNotify`

  Destroy notifier to free `user_data`.