libwebsockets
Lightweight C library for HTML5 websockets
lws-client.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
31 
38  LCCSCF_USE_SSL = (1 << 0),
39  LCCSCF_ALLOW_SELFSIGNED = (1 << 1),
40  LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2),
41  LCCSCF_ALLOW_EXPIRED = (1 << 3),
42  LCCSCF_ALLOW_INSECURE = (1 << 4),
43  LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM = (1 << 5),
44  LCCSCF_H2_QUIRK_OVERFLOWS_TXCR = (1 << 6),
45  LCCSCF_H2_AUTH_BEARER = (1 << 7),
46  LCCSCF_H2_HEXIFY_AUTH_TOKEN = (1 << 8),
47  LCCSCF_H2_MANUAL_RXFLOW = (1 << 9),
48  LCCSCF_HTTP_MULTIPART_MIME = (1 << 10),
49  LCCSCF_HTTP_X_WWW_FORM_URLENCODED = (1 << 11),
50  LCCSCF_HTTP_NO_FOLLOW_REDIRECT = (1 << 12),
51 
52  LCCSCF_PIPELINE = (1 << 16),
60  LCCSCF_MUXABLE_STREAM = (1 << 17),
61  LCCSCF_H2_PRIOR_KNOWLEDGE = (1 << 18),
62  LCCSCF_WAKE_SUSPEND__VALIDITY = (1 << 19),
63  /* our validity checks are important enough to wake from suspend */
64  LCCSCF_PRIORITIZE_READS = (1 << 20),
75 };
76 
81  struct lws_context *context;
83  const char *address;
85  int port;
89  const char *path;
91  const char *host;
93  const char *origin;
95  const char *protocol;
99  void *userdata;
101  const void *client_exts;
103  const char *method;
108  struct lws *parent_wsi;
112  const char *uri_replace_from;
115  const char *uri_replace_to;
117  struct lws_vhost *vhost;
119  struct lws **pwsi;
130  const char *iface;
133  const char *local_protocol_name;
140  const char *alpn;
147  struct lws_sequencer *seq;
174 #if defined(LWS_ROLE_MQTT)
175  const lws_mqtt_client_connect_param_t *mqtt_cp;
176 #else
177  void *mqtt_cp;
178 #endif
179 
180  uint16_t keep_warm_secs;
186  /* Add new things just above here ---^
187  * This is part of the ABI, don't needlessly break compatibility
188  *
189  * The below is to ensure later library versions with new
190  * members added above will see 0 (default) even if the app
191  * was not built against the newer headers.
192  */
193 
194  void *_unused[4];
195 };
196 
204 LWS_VISIBLE LWS_EXTERN struct lws *
206 
232 LWS_VISIBLE LWS_EXTERN int
234  struct lws_vhost *vhost);
255 LWS_VISIBLE LWS_EXTERN int
256 lws_http_client_read(struct lws *wsi, char **buf, int *len);
257 
269 LWS_VISIBLE LWS_EXTERN unsigned int
271 
283 LWS_VISIBLE LWS_EXTERN int
285  const uint8_t *der, size_t der_len);
286 
306 LWS_VISIBLE LWS_EXTERN void
307 lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
308 
323 LWS_VISIBLE LWS_EXTERN int
324 lws_client_http_multipart(struct lws *wsi, const char *name,
325  const char *filename, const char *content_type,
326  char **p, char *end);
327 
340 LWS_VISIBLE LWS_EXTERN int
341 lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
342 
LWS_VISIBLE LWS_EXTERN void lws_client_http_body_pending(struct lws *wsi, int something_left_to_send)
LWS_VISIBLE LWS_EXTERN int lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_http_client_read(struct lws *wsi, char **buf, int *len)
LWS_VISIBLE LWS_EXTERN int lws_client_http_multipart(struct lws *wsi, const char *name, const char *filename, const char *content_type, char **p, char *end)
LWS_VISIBLE LWS_EXTERN int lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN struct lws * lws_client_connect_via_info(const struct lws_client_connect_info *ccinfo)
LWS_VISIBLE LWS_EXTERN unsigned int lws_http_client_http_response(struct lws *wsi)
lws_client_connect_ssl_connection_flags
Definition: lws-client.h:37
LWS_VISIBLE LWS_EXTERN int lws_tls_client_vhost_extra_cert_mem(struct lws_vhost *vh, const uint8_t *der, size_t der_len)
@ LCCSCF_PIPELINE
Definition: lws-client.h:52
@ LCCSCF_PRIORITIZE_READS
Definition: lws-client.h:64
Definition: lws-client.h:80
const char * uri_replace_from
Definition: lws-client.h:112
struct lws ** pwsi
Definition: lws-client.h:119
const char * alpn
Definition: lws-client.h:140
const lws_retry_bo_t * retry_and_idle_policy
Definition: lws-client.h:159
int port
Definition: lws-client.h:85
struct lws_vhost * vhost
Definition: lws-client.h:117
struct lws * parent_wsi
Definition: lws-client.h:108
int ietf_version_or_minus_one
Definition: lws-client.h:97
const char * path
Definition: lws-client.h:89
const char * origin
Definition: lws-client.h:93
void * userdata
Definition: lws-client.h:99
int ssl_connection
Definition: lws-client.h:87
const char * uri_replace_to
Definition: lws-client.h:115
const char * host
Definition: lws-client.h:91
void * opaque_user_data
Definition: lws-client.h:152
const char * address
Definition: lws-client.h:83
const char * method
Definition: lws-client.h:103
const void * client_exts
Definition: lws-client.h:101
uint8_t sys_tls_client_cert
Definition: lws-client.h:169
const char * protocol
Definition: lws-client.h:95
const char * local_protocol_name
Definition: lws-client.h:133
struct lws_sequencer * seq
Definition: lws-client.h:147
const char * iface
Definition: lws-client.h:130
void * _unused[4]
Definition: lws-client.h:194
int manual_initial_tx_credit
Definition: lws-client.h:164
uint16_t keep_warm_secs
Definition: lws-client.h:180
struct lws_context * context
Definition: lws-client.h:81
Definition: lws-context-vhost.h:257
Definition: lws-mqtt.h:62
Definition: lws-retry.h:25