zhttp_request(3)

zhttp_request(3)

CZMQ Manual - CZMQ/1.4.1

Name

zhttp_request - Class for zhttp server request.

Synopsis

//  This is a draft class, and may change without notice. It is disabled in
//  stable builds by default. If you use this in applications, please ask
//  for it to be pushed to stable state. Use --enable-drafts to enable.
#ifdef CZMQ_BUILD_DRAFT_API
//  *** Draft method, for development use, may change without warning ***
//  Create a new http request.
CZMQ_EXPORT zhttp_request_t *
    zhttp_request_new (void);

//  *** Draft method, for development use, may change without warning ***
//  Destroy an http request.
CZMQ_EXPORT void
    zhttp_request_destroy (zhttp_request_t **self_p);

//  *** Draft method, for development use, may change without warning ***
//  Receive a new request from zhttp_server.
//  Return the underlying connection if successful, to be used when calling zhttp_response_send.
CZMQ_EXPORT void *
    zhttp_request_recv (zhttp_request_t *self, zsock_t *sock);

//  *** Draft method, for development use, may change without warning ***
//  Send a request to zhttp_client.
//  Url and the request path will be concatenated.
//  This behavior is useful for url rewrite and reverse proxy.
//
//  Send also allow two user provided arguments which will be returned with the response.
//  The reason for two, is to be able to pass around the server connection when forwarding requests or both a callback function and an arg.
CZMQ_EXPORT int
    zhttp_request_send (zhttp_request_t *self, zhttp_client_t *client, int timeout, void *arg, void *arg2);

//  *** Draft method, for development use, may change without warning ***
//  Get the request method
CZMQ_EXPORT const char *
    zhttp_request_method (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Set the request method
CZMQ_EXPORT void
    zhttp_request_set_method (zhttp_request_t *self, const char *method);

//  *** Draft method, for development use, may change without warning ***
//  Get the request url.
//  When receiving a request from http server this is only the path part of the url.
CZMQ_EXPORT const char *
    zhttp_request_url (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Set the request url
//  When sending a request to http client this should be full url.
CZMQ_EXPORT void
    zhttp_request_set_url (zhttp_request_t *self, const char *url);

//  *** Draft method, for development use, may change without warning ***
//  Get the request content type
CZMQ_EXPORT const char *
    zhttp_request_content_type (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Set the request content type
CZMQ_EXPORT void
    zhttp_request_set_content_type (zhttp_request_t *self, const char *content_type);

//  *** Draft method, for development use, may change without warning ***
//  Get the content length of the request
CZMQ_EXPORT size_t
    zhttp_request_content_length (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Get the headers of the request
CZMQ_EXPORT zhash_t *
    zhttp_request_headers (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Get the content of the request.
CZMQ_EXPORT const char *
    zhttp_request_content (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Get the content of the request.
//  Caller owns return value and must destroy it when done.
CZMQ_EXPORT char *
    zhttp_request_get_content (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Set the content of the request.
//  Content must by dynamically allocated string.
//  Takes ownership of the content.
CZMQ_EXPORT void
    zhttp_request_set_content (zhttp_request_t *self, char **content);

//  *** Draft method, for development use, may change without warning ***
//  Set the content of the request..
//  The content is assumed to be constant-memory and will therefore not be copied or deallocated in any way.
CZMQ_EXPORT void
    zhttp_request_set_content_const (zhttp_request_t *self, const char *content);

//  *** Draft method, for development use, may change without warning ***
//  Set the content to NULL
CZMQ_EXPORT void
    zhttp_request_reset_content (zhttp_request_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Match the path of the request.
//  Support wildcards with '%s' symbol inside the match string.
//  Matching wildcards until the next '/', '?' or '\0'.
//  On successful match the variadic arguments will be filled with the matching strings.
//  On successful match the method is modifying the url field and break it into substrings.
//  If you need to use the url, do it before matching or take a copy.
//
//  User must not free the variadic arguments as they are part of the url.
//
//  To use the percent symbol, just double it, e.g "%%something".
//
//  Example:
//  if (zhttp_request_match (request, "POST", "/send/%s/%s", &name, &id))
CZMQ_EXPORT bool
    zhttp_request_match (zhttp_request_t *self, const char *method, const char *path, ...);

//  *** Draft method, for development use, may change without warning ***
//  Self test of this class.
CZMQ_EXPORT void
    zhttp_request_test (bool verbose);

#endif // CZMQ_BUILD_DRAFT_API
Please add '@interface' section in './../src/zhttp_request.c'.

Description

zhttp_request - zhttp server request. Class can be reused.

Please add @discuss section in ./../src/zhttp_request.c.

Example

From zhttp_request_test method

Please add '@selftest' section in './../src/zhttp_request.c'.

Authors

The CZMQ manual was written by Pieter Hintjens<moc.xitami|hp#moc.xitami|hp>.

Resources

Main web site: http://czmq.zeromq.org/

Report bugs to the ØMQ development mailing list: <gro.qmorez.stsil|ved-qmorez#gro.qmorez.stsil|ved-qmorez>

Copyright

Copyright (c) 1991-2010 iMatix Corporation and contributors. License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>. This is free software: you are free to change it and redistribute it. There is NO WARRANTY, to the extent permitted by law. For details see the files COPYING and COPYING.LESSER included with the CZMQ distribution.