|
1 | 1 | #include "asio.h" |
2 | 2 |
|
3 | | -string http_get(string path, string type, u32 numof, ...) { |
| 3 | +string uv_http_get(string path, string type, u32 numof, ...) { |
4 | 4 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
5 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 5 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
6 | 6 | throw(logic_error); |
7 | 7 |
|
8 | 8 | va_list headers; |
9 | 9 | va_start(headers, numof); |
10 | 10 | string req = http_request(this->http, HTTP_GET, path, type, nullptr, numof, headers); |
11 | 11 | va_end(headers); |
12 | 12 |
|
| 13 | + stream_write(this->stream, req); |
| 14 | + |
13 | 15 | return req; |
14 | 16 | } |
15 | 17 |
|
16 | | -string http_post(string path, string data, string type, u32 numof, ...) { |
| 18 | +string uv_http_post(string path, string data, string type, u32 numof, ...) { |
17 | 19 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
18 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 20 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
19 | 21 | throw(logic_error); |
20 | 22 |
|
21 | 23 | va_list headers; |
22 | 24 | va_start(headers, numof); |
23 | 25 | string req = http_request(this->http, HTTP_POST, path, type, data, numof, headers); |
24 | 26 | va_end(headers); |
25 | 27 |
|
| 28 | + stream_write(this->stream, req); |
| 29 | + |
26 | 30 | return req; |
27 | 31 | } |
28 | 32 |
|
29 | | -string http_delete(string path, string data, u32 numof, ...) { |
| 33 | +string uv_http_delete(string path, string data, u32 numof, ...) { |
30 | 34 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
31 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 35 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
32 | 36 | throw(logic_error); |
33 | 37 |
|
34 | 38 | va_list headers; |
35 | 39 | va_start(headers, numof); |
36 | 40 | string req = http_request(this->http, HTTP_DELETE, path, nullptr, data, numof, headers); |
37 | 41 | va_end(headers); |
38 | 42 |
|
| 43 | + stream_write(this->stream, req); |
| 44 | + |
39 | 45 | return req; |
40 | 46 | } |
41 | 47 |
|
42 | | -string http_patch(string path, string data, u32 numof, ...) { |
| 48 | +string uv_http_patch(string path, string data, u32 numof, ...) { |
43 | 49 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
44 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 50 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
45 | 51 | throw(logic_error); |
46 | 52 |
|
47 | 53 | va_list headers; |
48 | 54 | va_start(headers, numof); |
49 | 55 | string req = http_request(this->http, HTTP_PATCH, path, nullptr, data, numof, headers); |
50 | 56 | va_end(headers); |
51 | 57 |
|
| 58 | + stream_write(this->stream, req); |
| 59 | + |
52 | 60 | return req; |
53 | 61 | } |
54 | 62 |
|
55 | | -string http_options(string path, u32 numof, ...) { |
| 63 | +string uv_http_options(string path, u32 numof, ...) { |
56 | 64 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
57 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 65 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
58 | 66 | throw(logic_error); |
59 | 67 |
|
60 | 68 | va_list headers; |
61 | 69 | va_start(headers, numof); |
62 | 70 | string req = http_request(this->http, HTTP_OPTIONS, path, nullptr, nullptr, numof, headers); |
63 | 71 | va_end(headers); |
64 | 72 |
|
| 73 | + stream_write(this->stream, req); |
| 74 | + |
65 | 75 | return req; |
66 | 76 | } |
67 | 77 |
|
68 | | -string http_head(string path, u32 numof, ...) { |
| 78 | +string uv_http_head(string path, u32 numof, ...) { |
69 | 79 | uv_tls_t *this = (uv_tls_t *)coro_data(); |
70 | | - if (!is_type(this, (raii_type)ASIO_ASYNC_TLS)) |
| 80 | + if (!is_type(this, (raii_type)ASIO_TLS)) |
71 | 81 | throw(logic_error); |
72 | 82 |
|
73 | 83 | va_list headers; |
74 | 84 | va_start(headers, numof); |
75 | 85 | string req = http_request(this->http, HTTP_HEAD, path, nullptr, nullptr, numof, headers); |
76 | 86 | va_end(headers); |
77 | 87 |
|
| 88 | + stream_write(this->stream, req); |
| 89 | + |
78 | 90 | return req; |
79 | 91 | } |
80 | 92 |
|
81 | | -RAII_INLINE void http_this(uv_tls_t *socket) { |
82 | | - if (is_type(socket, (raii_type)ASIO_ASYNC_TLS) && is_empty(coro_data())) |
83 | | - coro_data_set(coro_active(), (void_t)socket); |
| 93 | +RAII_INLINE void uv_this(void_t *data, asio_types type) { |
| 94 | + if (is_type(socket, (raii_type)type) && is_empty(coro_data())) |
| 95 | + coro_data_set(coro_active(), (void_t)data); |
84 | 96 |
|
85 | 97 | throw(logic_error); |
86 | 98 | } |
0 commit comments