diff options
author | Joe Orton <joe@manyfish.uk> | 2021-04-15 21:02:14 +0100 |
---|---|---|
committer | Joe Orton <joe@manyfish.uk> | 2021-04-15 21:02:14 +0100 |
commit | 42c9d0e7664fc9cb44f320e7c97f1ee106d88ebd (patch) | |
tree | a3cfb58693c6bb1e79e7bcfe65ea324307dfded6 | |
parent | 9af6544cd95e068e0a68c75a7d7d21d2ee0b5de7 (diff) | |
download | neon-git-42c9d0e7664fc9cb44f320e7c97f1ee106d88ebd.tar.gz |
Update terminology for RFC 7230:
* src/ne_request.c (struct ne_request_s): Rename the "uri" field to
"target".
(ne_request_create, build_request, ne_request_destroy): Update
accordingly.
* src/ne_request.h: Clarify that the ne_create_request_fn hook
is passed the request-target.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/ne_request.c | 16 | ||||
-rw-r--r-- | src/ne_request.h | 9 |
3 files changed, 15 insertions, 12 deletions
@@ -8,6 +8,8 @@ Changes in release 0.32.0: - ne_auth.h: use of non-ASCII usernames with the ne_auth_creds callback type is now rejected for Digest auth since the encoding is not specified. ne_add_auth() can be used instead. + - ne_request.h: the ne_create_request_fn callback is passed the + request-target using RFC 7230 terminology * New interfaces and features: - ne_string.h: added ne_strhash(), ne_vstrhash(), ne_strparam() - ne_auth.h: added RFC 7616 (Digest authentication) support, diff --git a/src/ne_request.c b/src/ne_request.c index 6b4e62f..4cfd524 100644 --- a/src/ne_request.c +++ b/src/ne_request.c @@ -87,7 +87,7 @@ struct field { #define HH_HV_TRANSFER_ENCODING (0x07) struct ne_request_s { - char *method, *uri; /* method and Request-URI */ + char *method, *target; /* method and request-target */ ne_buffer *headers; /* request headers */ @@ -526,17 +526,18 @@ ne_request *ne_request_create(ne_session *sess, /* Only use an absoluteURI here when we might be using an HTTP * proxy, and SSL is in use: some servers can't parse them. */ if (sess->any_proxy_http && !req->session->use_ssl && path[0] == '/') - req->uri = ne_concat(req->session->scheme, "://", - req->session->server.hostport, path, NULL); + req->target = ne_concat(req->session->scheme, "://", + req->session->server.hostport, + path, NULL); else - req->uri = ne_strdup(path); + req->target = ne_strdup(path); { struct hook *hk; for (hk = sess->create_req_hooks; hk != NULL; hk = hk->next) { ne_create_request_fn fn = (ne_create_request_fn)hk->fn; - fn(req, hk->userdata, req->method, req->uri); + fn(req, hk->userdata, req->method, req->target); } } @@ -724,7 +725,7 @@ void ne_request_destroy(ne_request *req) struct body_reader *rdr, *next_rdr; struct hook *hk, *next_hk; - ne_free(req->uri); + ne_free(req->target); ne_free(req->method); for (rdr = req->body_readers; rdr != NULL; rdr = next_rdr) { @@ -885,7 +886,8 @@ static ne_buffer *build_request(ne_request *req) ne_buffer *buf = ne_buffer_create(); /* Add Request-Line and headers: */ - ne_buffer_concat(buf, req->method, " ", req->uri, " HTTP/1.1" EOL, NULL); + ne_buffer_concat(buf, req->method, " ", req->target, " HTTP/1.1" EOL, + NULL); /* Add custom headers: */ ne_buffer_append(buf, req->headers->data, ne_buffer_size(req->headers)); diff --git a/src/ne_request.h b/src/ne_request.h index f65f29e..a0268a1 100644 --- a/src/ne_request.h +++ b/src/ne_request.h @@ -238,12 +238,11 @@ int ne_get_request_flag(ne_request *req, ne_request_flag flag); typedef void (*ne_free_hooks)(void *cookie); -/* Hook called when a request is created; passed the request method, - * and the string used as the Request-URI (note that this may be a - * absolute URI if a proxy is in use, an absolute path, a "*", etc). - * A create_request hook is called exactly once per request. */ +/* Hook called when a request is created; passed the method and + * request-target as used in the request-line (RFC7230ยง5.3). The + * create_request hook is called exactly once per request. */ typedef void (*ne_create_request_fn)(ne_request *req, void *userdata, - const char *method, const char *requri); + const char *method, const char *target); void ne_hook_create_request(ne_session *sess, ne_create_request_fn fn, void *userdata); |