]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #1469: dohclient: DoH POST missing content-length → :status
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 30 Jun 2026 10:14:00 +0000 (12:14 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 30 Jun 2026 10:14:00 +0000 (12:14 +0200)
  400 from strict resolvers (Cloudflare, Mullvad).

doc/Changelog
testcode/dohclient.c

index 6a68008cbf98986344e257c7bcf52bcd6ea54b87..9626562e52a30966de1595ae2504410a8d5e083b 100644 (file)
@@ -1,3 +1,7 @@
+30 June 2026: Wouter
+       - Fix #1469: dohclient: DoH POST missing content-length → :status
+         400 from strict resolvers (Cloudflare, Mullvad).
+
 26 June 2026: Wouter
        - Merge #1467: daemon: fix DEREF_AFTER_NULL.EX.COND on
          worker_init. This fixes error handling if the worker
index 8d8adaf5df34cc7cc3cb7dafd9e418fc067dbda6..08250ef3ae65ad837ff425497c6b067be7f96dab 100644 (file)
@@ -146,7 +146,9 @@ submit_query(struct http2_session* h2_session, struct sldns_buffer* buf)
 {
        int32_t stream_id;
        struct http2_stream* h2_stream;
-       nghttp2_nv headers[5];
+       nghttp2_nv headers[6];
+       size_t num_headers = 5;
+       char clen[16];
        char* qb64;
        size_t qb64_size;
        size_t qb64_expected_size;
@@ -194,9 +196,16 @@ submit_query(struct http2_session* h2_session, struct sldns_buffer* buf)
        headers[3].value = (uint8_t*)h2_session->authority;
        headers[4].name = (uint8_t*)"content-type";
        headers[4].value = (uint8_t*)h2_session->content_type;
+       if(h2_session->post) {
+               snprintf(clen, sizeof(clen), "%u",
+                       (unsigned)sldns_buffer_remaining(buf));
+               headers[5].name = (uint8_t*)"content-length";
+               headers[5].value = (uint8_t*)clen;
+               num_headers = 6;
+       }
 
        printf("Request headers\n");
-       for(i=0; i<sizeof(headers)/sizeof(headers[0]); i++) {
+       for(i=0; i<num_headers; i++) {
                headers[i].namelen = strlen((char*)headers[i].name);
                headers[i].valuelen = strlen((char*)headers[i].value);
                headers[i].flags = NGHTTP2_NV_FLAG_NONE;
@@ -204,7 +213,7 @@ submit_query(struct http2_session* h2_session, struct sldns_buffer* buf)
        }
 
        stream_id = nghttp2_submit_request(h2_session->session, NULL, headers,
-               sizeof(headers)/sizeof(headers[0]),
+               num_headers,
                (h2_session->post) ? &data_prd : NULL, h2_stream);
        if(stream_id < 0) {
                printf("Failed to submit nghttp2 request");