Project homepage Mailing List  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1600413193, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"", "f":3, "items": [ {"schema":"libjg2-1", "cid":"c25e46e972226e927cce6c7ce7e3cd2b", "oid":{ "oid": "c2be82f4f16e8ef245f02414001c1c65bdb280f9", "alias": [ "refs/heads/master"]},"blobname": "include/libwebsockets/lws-client.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*! \u005cdefgroup client Client related functions\n * ##Client releated functions\n * \u005cingroup lwsapi\n *\n * */\n///@{\n\n/** enum lws_client_connect_ssl_connection_flags - flags that may be used\n * with struct lws_client_connect_info ssl_connection member to control if\n * and how SSL checks apply to the client connection being created\n */\n\nenum lws_client_connect_ssl_connection_flags {\n\tLCCSCF_USE_SSL \t\t\t\t\u003d (1 \u003c\u003c 0),\n\tLCCSCF_ALLOW_SELFSIGNED\t\t\t\u003d (1 \u003c\u003c 1),\n\tLCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK\t\u003d (1 \u003c\u003c 2),\n\tLCCSCF_ALLOW_EXPIRED\t\t\t\u003d (1 \u003c\u003c 3),\n\tLCCSCF_ALLOW_INSECURE\t\t\t\u003d (1 \u003c\u003c 4),\n\tLCCSCF_H2_QUIRK_NGHTTP2_END_STREAM\t\u003d (1 \u003c\u003c 5),\n\tLCCSCF_H2_QUIRK_OVERFLOWS_TXCR\t\t\u003d (1 \u003c\u003c 6),\n\tLCCSCF_H2_AUTH_BEARER\t\t\t\u003d (1 \u003c\u003c 7),\n\tLCCSCF_H2_HEXIFY_AUTH_TOKEN\t\t\u003d (1 \u003c\u003c 8),\n\tLCCSCF_H2_MANUAL_RXFLOW\t\t\t\u003d (1 \u003c\u003c 9),\n\tLCCSCF_HTTP_MULTIPART_MIME\t\t\u003d (1 \u003c\u003c 10),\n\tLCCSCF_HTTP_X_WWW_FORM_URLENCODED\t\u003d (1 \u003c\u003c 11),\n\tLCCSCF_HTTP_NO_FOLLOW_REDIRECT\t\t\u003d (1 \u003c\u003c 12),\n\n\tLCCSCF_PIPELINE\t\t\t\t\u003d (1 \u003c\u003c 16),\n\t\t/**\u003c Serialize / pipeline multiple client connections\n\t\t * on a single connection where possible.\n\t\t *\n\t\t * HTTP/1.0: possible if Keep-Alive: yes sent by server\n\t\t * HTTP/1.1: always possible... uses pipelining\n\t\t * HTTP/2: always possible... uses parallel streams\n\t\t */\n\tLCCSCF_MUXABLE_STREAM\t\t\t\u003d (1 \u003c\u003c 17),\n\tLCCSCF_H2_PRIOR_KNOWLEDGE\t\t\u003d (1 \u003c\u003c 18),\n\tLCCSCF_WAKE_SUSPEND__VALIDITY\t\t\u003d (1 \u003c\u003c 19),\n\t/* our validity checks are important enough to wake from suspend */\n\tLCCSCF_PRIORITIZE_READS\t\t\t\u003d (1 \u003c\u003c 20),\n\t/**\u003c\n\t * Normally lws balances reads and writes on all connections, so both\n\t * are possible even on busy connections, and we go around the event\n\t * loop more often to facilitate that, even if there is pending data.\n\t *\n\t * This flag indicates that you want to handle any pending reads on this\n\t * connection without yielding the service loop for anything else. This\n\t * means you may block other connection processing in favour of incoming\n\t * data processing on this one if it receives back to back incoming rx.\n\t */\n};\n\n/** struct lws_client_connect_info - parameters to connect with when using\n *\t\t\t\t lws_client_connect_via_info() */\n\nstruct lws_client_connect_info {\n\tstruct lws_context *context;\n\t/**\u003c lws context to create connection in */\n\tconst char *address;\n\t/**\u003c remote address to connect to */\n\tint port;\n\t/**\u003c remote port to connect to */\n\tint ssl_connection;\n\t/**\u003c 0, or a combination of LCCSCF_ flags */\n\tconst char *path;\n\t/**\u003c uri path */\n\tconst char *host;\n\t/**\u003c content of host header */\n\tconst char *origin;\n\t/**\u003c content of origin header */\n\tconst char *protocol;\n\t/**\u003c list of ws protocols we could accept */\n\tint ietf_version_or_minus_one;\n\t/**\u003c deprecated: currently leave at 0 or -1 */\n\tvoid *userdata;\n\t/**\u003c if non-NULL, use this as wsi user_data instead of malloc it */\n\tconst void *client_exts;\n\t/**\u003c UNUSED... provide in info.extensions at context creation time */\n\tconst char *method;\n\t/**\u003c if non-NULL, do this http method instead of ws[s] upgrade.\n\t * use \u0022GET\u0022 to be a simple http client connection. \u0022RAW\u0022 gets\n\t * you a connected socket that lws itself will leave alone once\n\t * connected. */\n\tstruct lws *parent_wsi;\n\t/**\u003c if another wsi is responsible for this connection, give it here.\n\t * this is used to make sure if the parent closes so do any\n\t * child connections first. */\n\tconst char *uri_replace_from;\n\t/**\u003c if non-NULL, when this string is found in URIs in\n\t * text/html content-encoding, it's replaced with uri_replace_to */\n\tconst char *uri_replace_to;\n\t/**\u003c see uri_replace_from */\n\tstruct lws_vhost *vhost;\n\t/**\u003c vhost to bind to (used to determine related SSL_CTX) */\n\tstruct lws **pwsi;\n\t/**\u003c if not NULL, store the new wsi here early in the connection\n\t * process. Although we return the new wsi, the call to create the\n\t * client connection does progress the connection somewhat and may\n\t * meet an error that will result in the connection being scrubbed and\n\t * NULL returned. While the wsi exists though, he may process a\n\t * callback like CLIENT_CONNECTION_ERROR with his wsi: this gives the\n\t * user callback a way to identify which wsi it is that faced the error\n\t * even before the new wsi is returned and even if ultimately no wsi\n\t * is returned.\n\t */\n\tconst char *iface;\n\t/**\u003c NULL to allow routing on any interface, or interface name or IP\n\t * to bind the socket to */\n\tconst char *local_protocol_name;\n\t/**\u003c NULL: .protocol is used both to select the local protocol handler\n\t * to bind to and as the list of remote ws protocols we could\n\t * accept.\n\t * non-NULL: this protocol name is used to bind the connection to\n\t * the local protocol handler. .protocol is used for the\n\t * list of remote ws protocols we could accept */\n\tconst char *alpn;\n\t/**\u003c NULL: allow lws default ALPN list, from vhost if present or from\n\t * list of roles built into lws\n\t * non-NULL: require one from provided comma-separated list of alpn\n\t * tokens\n\t */\n\n\tstruct lws_sequencer *seq;\n\t/**\u003c NULL, or an lws_seq_t that wants to be given messages about\n\t * this wsi's lifecycle as it connects, errors or closes.\n\t */\n\n\tvoid *opaque_user_data;\n\t/**\u003c This data has no meaning to lws but is applied to the client wsi\n\t * and can be retrieved by user code with lws_get_opaque_user_data().\n\t * It's also provided with sequencer messages if the wsi is bound to\n\t * an lws_seq_t.\n\t */\n\n\tconst lws_retry_bo_t *retry_and_idle_policy;\n\t/**\u003c optional retry and idle policy to apply to this connection.\n\t * Currently only the idle parts are applied to the connection.\n\t */\n\n\tint\t\tmanual_initial_tx_credit;\n\t/**\u003c if LCCSCF_H2_MANUAL_REFLOW is set, this becomes the initial tx\n\t * credit for the stream.\n\t */\n\n\tuint8_t\t\tsys_tls_client_cert;\n\t/**\u003c 0 means no client cert. 1+ means apply lws_system client cert 0+\n\t * to the client connection.\n\t */\n\n#if defined(LWS_ROLE_MQTT)\n\tconst lws_mqtt_client_connect_param_t *mqtt_cp;\n#else\n\tvoid\t\t*mqtt_cp;\n#endif\n\n\tuint16_t\tkeep_warm_secs;\n\t/**\u003c 0 means 5s. If the client connection to the endpoint becomes idle,\n\t * defer closing it for this many seconds in case another outgoing\n\t * connection to the same endpoint turns up.\n\t */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility\n\t *\n\t * The below is to ensure later library versions with new\n\t * members added above will see 0 (default) even if the app\n\t * was not built against the newer headers.\n\t */\n\n\tvoid *_unused[4]; /**\u003c dummy */\n};\n\n/**\n * lws_client_connect_via_info() - Connect to another websocket server\n * \u005cparam ccinfo: pointer to lws_client_connect_info struct\n *\n *\tThis function creates a connection to a remote server using the\n *\tinformation provided in ccinfo.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_client_connect_via_info(const struct lws_client_connect_info *ccinfo);\n\n/**\n * lws_init_vhost_client_ssl() - also enable client SSL on an existing vhost\n *\n * \u005cparam info: client ssl related info\n * \u005cparam vhost: which vhost to initialize client ssl operations on\n *\n * You only need to call this if you plan on using SSL client connections on\n * the vhost. For non-SSL client connections, it's not necessary to call this.\n *\n * The following members of info are used during the call\n *\n *\t - options must have LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT set,\n *\t otherwise the call does nothing\n *\t - provided_client_ssl_ctx must be NULL to get a generated client\n *\t ssl context, otherwise you can pass a prepared one in by setting it\n *\t - ssl_cipher_list may be NULL or set to the client valid cipher list\n *\t - ssl_ca_filepath may be NULL or client cert filepath\n *\t - ssl_cert_filepath may be NULL or client cert filepath\n *\t - ssl_private_key_filepath may be NULL or client cert private key\n *\n * You must create your vhost explicitly if you want to use this, so you have\n * a pointer to the vhost. Create the context first with the option flag\n * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with\n * the same info struct.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_init_vhost_client_ssl(const struct lws_context_creation_info *info,\n\t\t\t struct lws_vhost *vhost);\n/**\n * lws_http_client_read() - consume waiting received http client data\n *\n * \u005cparam wsi: client connection\n * \u005cparam buf: pointer to buffer pointer - fill with pointer to your buffer\n * \u005cparam len: pointer to chunk length - fill with max length of buffer\n *\n * This is called when the user code is notified client http data has arrived.\n * The user code may choose to delay calling it to consume the data, for example\n * waiting until an onward connection is writeable.\n *\n * For non-chunked connections, up to len bytes of buf are filled with the\n * received content. len is set to the actual amount filled before return.\n *\n * For chunked connections, the linear buffer content contains the chunking\n * headers and it cannot be passed in one lump. Instead, this function will\n * call back LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ with in pointing to the\n * chunk start and len set to the chunk length. There will be as many calls\n * as there are chunks or partial chunks in the buffer.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_http_client_read(struct lws *wsi, char **buf, int *len);\n\n/**\n * lws_http_client_http_response() - get last HTTP response code\n *\n * \u005cparam wsi: client connection\n *\n * Returns the last server response code, eg, 200 for client http connections.\n *\n * You should capture this during the LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP\n * callback, because after that the memory reserved for storing the related\n * headers is freed and this value is lost.\n */\nLWS_VISIBLE LWS_EXTERN unsigned int\nlws_http_client_http_response(struct lws *wsi);\n\n/**\n * lws_tls_client_vhost_extra_cert_mem() - add more certs to vh client tls ctx\n *\n * \u005cparam vh: the vhost to give more client certs to\n * \u005cparam der: pointer to der format additional cert\n * \u005cparam der_len: size in bytes of der\n *\n * After the vhost is created with one cert for client verification, you\n * can add additional, eg, intermediate, certs to the client tls context\n * of the vhost, for use with validating the incoming server cert(s).\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_client_vhost_extra_cert_mem(struct lws_vhost *vh,\n\t\tconst uint8_t *der, size_t der_len);\n\n/**\n * lws_client_http_body_pending() - control if client connection needs to send body\n *\n * \u005cparam wsi: client connection\n * \u005cparam something_left_to_send: nonzero if need to send more body, 0 (default)\n * \t\t\t\tif nothing more to send\n *\n * If you will send payload data with your HTTP client connection, eg, for POST,\n * when you set the related http headers in\n * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER callback you should also call\n * this API with something_left_to_send nonzero, and call\n * lws_callback_on_writable(wsi);\n *\n * After sending the headers, lws will call your callback with\n * LWS_CALLBACK_CLIENT_HTTP_WRITEABLE reason when writable. You can send the\n * next part of the http body payload, calling lws_callback_on_writable(wsi);\n * if there is more to come, or lws_client_http_body_pending(wsi, 0); to\n * let lws know the last part is sent and the connection can move on.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_client_http_body_pending(struct lws *wsi, int something_left_to_send);\n\n/**\n * lws_client_http_multipart() - issue appropriate multipart header or trailer\n *\n * \u005cparam wsi: client connection\n * \u005cparam name: multipart header name field, or NULL if end of multipart\n * \u005cparam filename: multipart header filename field, or NULL if none\n * \u005cparam content_type: multipart header content-type part, or NULL if none\n * \u005cparam p: pointer to position in buffer\n * \u005cparam end: end of buffer\n *\n * This issues a multipart mime boundary, or terminator if name \u003d NULL.\n *\n * Returns 0 if OK or nonzero if couldn't fit in buffer\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_client_http_multipart(struct lws *wsi, const char *name,\n\t\t\t const char *filename, const char *content_type,\n\t\t\t char **p, char *end);\n\n/**\n * lws_http_basic_auth_gen() - helper to encode client basic auth string\n *\n * \u005cparam user: user name\n * \u005cparam pw: password\n * \u005cparam buf: where to store base64 result\n * \u005cparam len: max usable size of buf\n *\n * Encodes a username and password in Basic Auth format for use with the\n * Authorization header. On return, buf is filled with something like\n * \u0022Basic QWxhZGRpbjpPcGVuU2VzYW1l\u0022.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);\n\n///@}\n","s":{"c":1600413193,"u": 468}} ],"g": 3690,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}