1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
//
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#include "core/nng_impl.h"
#include "http_api.h"
#include "nng/http.h"
// Symbols in this file are "public" versions of the HTTP API.
// These are suitable for exposure to applications.
void
nng_http_close(nng_http *conn)
{
// API version of this closes *and* frees the structure.
nni_http_conn_fini(conn);
}
void
nng_http_read(nng_http *conn, nng_aio *aio)
{
nni_http_read(conn, aio);
}
void
nng_http_read_all(nng_http *conn, nng_aio *aio)
{
nni_http_read_full(conn, aio);
}
void
nng_http_write(nng_http *conn, nng_aio *aio)
{
nni_http_write(conn, aio);
}
void
nng_http_write_all(nng_http *conn, nng_aio *aio)
{
nni_http_write_full(conn, aio);
}
void
nng_http_write_request(nng_http *conn, nng_aio *aio)
{
nni_http_write_req(conn, aio);
}
void
nng_http_write_response(nng_http *conn, nng_aio *aio)
{
nni_http_write_res(conn, aio);
}
void
nng_http_read_response(nng_http *conn, nng_aio *aio)
{
nni_http_read_res(conn, aio);
}
nng_err
nng_http_server_hold(nng_http_server **srvp, const nng_url *url)
{
return (nni_http_server_init(srvp, url));
}
void
nng_http_server_release(nng_http_server *srv)
{
nni_http_server_fini(srv);
}
nng_err
nng_http_server_start(nng_http_server *srv)
{
return (nni_http_server_start(srv));
}
void
nng_http_server_stop(nng_http_server *srv)
{
nni_http_server_stop(srv);
}
nng_err
nng_http_server_add_handler(nng_http_server *srv, nng_http_handler *h)
{
return (nni_http_server_add_handler(srv, h));
}
nng_err
nng_http_server_del_handler(nng_http_server *srv, nng_http_handler *h)
{
return (nni_http_server_del_handler(srv, h));
}
nng_err
nng_http_server_set_error_page(
nng_http_server *srv, nng_http_status code, const char *body)
{
return (nni_http_server_set_error_page(srv, code, body));
}
nng_err
nng_http_server_set_tls(nng_http_server *srv, nng_tls_config *cfg)
{
return (nni_http_server_set_tls(srv, cfg));
}
nng_err
nng_http_server_get_tls(nng_http_server *srv, nng_tls_config **cfg)
{
return (nni_http_server_get_tls(srv, cfg));
}
nng_err
nng_http_server_get_addr(nng_http_server *srv, nng_sockaddr *addr)
{
size_t size = sizeof(nng_sockaddr);
if (srv == NULL || addr == NULL)
return NNG_EINVAL;
return (nni_http_server_get(
srv, NNG_OPT_LOCADDR, addr, &size, NNI_TYPE_SOCKADDR));
}
nng_err
nng_http_server_error(nng_http_server *srv, nng_http *conn)
{
return (nni_http_server_error(srv, conn));
}
void
nng_http_reset(nng_http *conn)
{
nni_http_conn_reset(conn);
}
|