[njs] Fetch: fixed compatibility with nginx-1.22 and below.
Dmitry Volyntsev
xeioex at nginx.com
Tue Feb 7 03:43:37 UTC 2023
details: https://hg.nginx.org/njs/rev/51f737b21b48
branches:
changeset: 2039:51f737b21b48
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Feb 03 22:17:53 2023 -0800
description:
Fetch: fixed compatibility with nginx-1.22 and below.
Previously, ngx_table_elt_t structure was used directly in njs fetch
code. This prevents from building with nginx-1.22 as the structure
was changed after nginx-1.22.
The fix is to use njs defined structure instead of ngx_table_elt_t.
This fixes #610 issue on Github.
diffstat:
nginx/ngx_js_fetch.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diffs (128 lines):
diff -r 69547623da14 -r 51f737b21b48 nginx/ngx_js_fetch.c
--- a/nginx/ngx_js_fetch.c Fri Feb 03 06:41:01 2023 -0800
+++ b/nginx/ngx_js_fetch.c Fri Feb 03 22:17:53 2023 -0800
@@ -47,6 +47,16 @@ typedef struct {
} ngx_js_http_chunk_parse_t;
+typedef struct ngx_js_tb_elt_s ngx_js_tb_elt_t;
+
+struct ngx_js_tb_elt_s {
+ ngx_uint_t hash;
+ ngx_str_t key;
+ ngx_str_t value;
+ ngx_js_tb_elt_t *next;
+};
+
+
typedef struct {
enum {
GUARD_NONE = 0,
@@ -651,7 +661,7 @@ ngx_js_ext_fetch(njs_vm_t *vm, njs_value
njs_value_t *init, *value;
ngx_js_http_t *http;
ngx_list_part_t *part;
- ngx_table_elt_t *h;
+ ngx_js_tb_elt_t *h;
ngx_js_request_t request;
ngx_connection_t *c;
ngx_resolver_ctx_t *ctx;
@@ -850,7 +860,7 @@ ngx_js_ext_headers_constructor(njs_vm_t
return NJS_ERROR;
}
- rc = ngx_list_init(&headers->header_list, pool, 4, sizeof(ngx_table_elt_t));
+ rc = ngx_list_init(&headers->header_list, pool, 4, sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
njs_vm_memory_error(vm);
return NJS_ERROR;
@@ -933,7 +943,7 @@ ngx_js_ext_response_constructor(njs_vm_t
pool = ngx_external_pool(vm, njs_vm_external_ptr(vm));
rc = ngx_list_init(&response->headers.header_list, pool, 4,
- sizeof(ngx_table_elt_t));
+ sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
njs_vm_memory_error(vm);
return NJS_ERROR;
@@ -1076,7 +1086,7 @@ ngx_js_headers_inherit(njs_vm_t *vm, ngx
njs_int_t ret;
ngx_uint_t i;
ngx_list_part_t *part;
- ngx_table_elt_t *h;
+ ngx_js_tb_elt_t *h;
part = &orig->header_list.part;
h = part->elts;
@@ -1900,7 +1910,7 @@ ngx_js_request_constructor(njs_vm_t *vm,
pool = ngx_external_pool(vm, external);
rc = ngx_list_init(&request->headers.header_list, pool, 4,
- sizeof(ngx_table_elt_t));
+ sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
njs_vm_memory_error(vm);
return NJS_ERROR;
@@ -2031,7 +2041,7 @@ ngx_js_request_constructor(njs_vm_t *vm,
*/
rc = ngx_list_init(&request->headers.header_list, pool, 4,
- sizeof(ngx_table_elt_t));
+ sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
njs_vm_memory_error(vm);
return NJS_ERROR;
@@ -2161,7 +2171,7 @@ ngx_js_headers_append(njs_vm_t *vm, ngx_
{
u_char *p, *end;
ngx_uint_t i;
- ngx_table_elt_t *h, **ph;
+ ngx_js_tb_elt_t *h, **ph;
ngx_list_part_t *part;
const njs_str_t *f;
@@ -2360,7 +2370,7 @@ ngx_js_http_process_headers(ngx_js_http_
if (http->response.headers.header_list.size == 0) {
rc = ngx_list_init(&http->response.headers.header_list, http->pool, 4,
- sizeof(ngx_table_elt_t));
+ sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
ngx_js_http_error(http, 0, "alloc failed");
return NGX_ERROR;
@@ -3149,7 +3159,7 @@ ngx_headers_js_get(njs_vm_t *vm, njs_val
size_t len;
njs_int_t rc;
ngx_uint_t i;
- ngx_table_elt_t *h, *ph;
+ ngx_js_tb_elt_t *h, *ph;
ngx_list_part_t *part;
ngx_js_headers_t *headers;
@@ -3296,7 +3306,7 @@ ngx_headers_js_ext_delete(njs_vm_t *vm,
njs_str_t name;
ngx_uint_t i;
ngx_list_part_t *part;
- ngx_table_elt_t *h;
+ ngx_js_tb_elt_t *h;
ngx_js_headers_t *headers;
headers = njs_vm_external(vm, ngx_http_js_fetch_headers_proto_id,
@@ -3478,7 +3488,7 @@ ngx_headers_js_ext_keys(njs_vm_t *vm, nj
ngx_uint_t i, k, length;
njs_value_t *start;
ngx_list_part_t *part;
- ngx_table_elt_t *h;
+ ngx_js_tb_elt_t *h;
ngx_js_headers_t *headers;
headers = njs_vm_external(vm, ngx_http_js_fetch_headers_proto_id, value);
@@ -3558,7 +3568,7 @@ ngx_headers_js_ext_set(njs_vm_t *vm, njs
njs_str_t name, value;
ngx_uint_t i;
ngx_list_part_t *part;
- ngx_table_elt_t *h, **ph, **pp;
+ ngx_js_tb_elt_t *h, **ph, **pp;
ngx_js_headers_t *headers;
headers = njs_vm_external(vm, ngx_http_js_fetch_headers_proto_id,
More information about the nginx-devel
mailing list