projects
/
project
/
uclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
example: create only one request
[project/uclient.git]
/
uclient-example.c
diff --git
a/uclient-example.c
b/uclient-example.c
index
3bf8d29
..
65ffc19
100644
(file)
--- a/
uclient-example.c
+++ b/
uclient-example.c
@@
-77,26
+77,17
@@
static void msg_connecting(struct uclient *cl)
fprintf(stderr, "Connecting to %s %s:%d\n", cl->url->host, addr, port);
}
fprintf(stderr, "Connecting to %s %s:%d\n", cl->url->host, addr, port);
}
-static void
example_request_sm
(struct uclient *cl)
+static void
init_request
(struct uclient *cl)
{
{
- static int i = 0;
-
- switch (i++) {
- case 0:
- uclient_connect(cl);
- msg_connecting(cl);
- uclient_http_set_request_type(cl, "HEAD");
- uclient_request(cl);
- break;
- case 1:
- uclient_connect(cl);
- uclient_http_set_request_type(cl, "GET");
- uclient_request(cl);
- break;
- default:
- uloop_end();
- break;
- };
+ uclient_connect(cl);
+ msg_connecting(cl);
+ uclient_http_set_request_type(cl, "GET");
+ uclient_request(cl);
+}
+
+static void request_done(struct uclient *cl)
+{
+ uloop_end();
}
static void example_eof(struct uclient *cl)
}
static void example_eof(struct uclient *cl)
@@
-109,14
+100,15
@@
static void example_eof(struct uclient *cl)
}
retries = 0;
}
retries = 0;
-
example_request_sm
(cl);
+
request_done
(cl);
}
static void example_error(struct uclient *cl, int code)
{
if (!quiet)
fprintf(stderr, "Error %d!\n", code);
}
static void example_error(struct uclient *cl, int code)
{
if (!quiet)
fprintf(stderr, "Error %d!\n", code);
- example_request_sm(cl);
+
+ request_done(cl);
}
static const struct uclient_cb cb = {
}
static const struct uclient_cb cb = {
@@
-225,7
+217,7
@@
int main(int argc, char **argv)
if (ssl_ctx)
uclient_http_set_ssl_ctx(cl, ssl_ops, ssl_ctx, verify);
if (ssl_ctx)
uclient_http_set_ssl_ctx(cl, ssl_ops, ssl_ctx, verify);
-
example_request_sm
(cl);
+
init_request
(cl);
uloop_run();
uloop_done();
uloop_run();
uloop_done();