X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=blobdiff_plain;f=uclient.h;h=961f52357c1b306cb5e73e96eeb4a5e5c66b90c2;hp=d328b145740aa677bec8a80d7f0a18bc07555b6b;hb=299b1af9c051248771537980ee2d16c29c61376d;hpb=c280d54e1bc79de4424fabc3fad011cc15587b81 diff --git a/uclient.h b/uclient.h index d328b14..961f523 100644 --- a/uclient.h +++ b/uclient.h @@ -1,3 +1,20 @@ +/* + * uclient - ustream based protocol client library + * + * Copyright (C) 2014 Felix Fietkau + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #ifndef __LIBUBOX_UCLIENT_H #define __LIBUBOX_UCLIENT_H @@ -8,6 +25,13 @@ struct uclient_cb; struct uclient_backend; +enum uclient_error_code { + UCLIENT_ERROR_UNKNOWN, + UCLIENT_ERROR_CONNECT, + UCLIENT_ERROR_SSL_INVALID_CERT, + UCLIENT_ERROR_SSL_CN_MISMATCH, +}; + struct uclient { const struct uclient_backend *backend; const struct uclient_cb *cb; @@ -16,7 +40,7 @@ struct uclient { void *priv; bool eof; - bool error; + int error_code; int status_code; struct blob_attr *meta; @@ -28,7 +52,7 @@ struct uclient_cb { void (*data_sent)(struct uclient *cl); void (*data_eof)(struct uclient *cl); void (*header_done)(struct uclient *cl); - void (*error)(struct uclient *cl); + void (*error)(struct uclient *cl, int code); }; struct uclient *uclient_new(const char *url, const struct uclient_cb *cb); @@ -47,8 +71,13 @@ int uclient_write(struct uclient *cl, char *buf, int len); int uclient_request(struct uclient *cl); /* HTTP */ +extern const struct uclient_backend uclient_backend_http; + int uclient_http_set_header(struct uclient *cl, const char *name, const char *value); int uclient_http_reset_headers(struct uclient *cl, const char *name, const char *value); int uclient_http_set_request_type(struct uclient *cl, const char *type); +bool uclient_http_redirect(struct uclient *cl); + +int uclient_http_set_ssl_ctx(struct uclient *cl, struct ustream_ssl_ctx *ctx, bool require_validation); #endif