Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package nng for openSUSE:Factory checked in at 2026-06-29 17:32:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nng (Old) and /work/SRC/openSUSE:Factory/.nng.new.11887 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nng" Mon Jun 29 17:32:18 2026 rev:9 rq:1362402 version:1.12.0 Changes: -------- --- /work/SRC/openSUSE:Factory/nng/nng.changes 2026-03-15 14:32:45.200342435 +0100 +++ /work/SRC/openSUSE:Factory/.nng.new.11887/nng.changes 2026-06-29 17:34:04.665679603 +0200 @@ -1,0 +2,8 @@ +Mon Jun 29 09:42:19 UTC 2026 - Martin Hauke <[email protected]> + +- Update to version 1.12 + * Stable fix task abort in #2225 + * fix(stable) http server: add modern MIME types to static + content map. + +------------------------------------------------------------------- Old: ---- nng-1.11.tar.gz New: ---- nng-1.12.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nng.spec ++++++ --- /var/tmp/diff_new_pack.NBfj89/_old 2026-06-29 17:34:05.669713954 +0200 +++ /var/tmp/diff_new_pack.NBfj89/_new 2026-06-29 17:34:05.673714091 +0200 @@ -19,7 +19,7 @@ %define sover 1 Name: nng -Version: 1.11 +Version: 1.12.0 Release: 0 Summary: Nanomsg NG - brokerless messaging License: MIT ++++++ nng-1.11.tar.gz -> nng-1.12.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/.github/workflows/darwin.yml new/nng-1.12.0/.github/workflows/darwin.yml --- old/nng-1.11/.github/workflows/darwin.yml 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/.github/workflows/darwin.yml 2026-06-09 23:32:43.000000000 +0200 @@ -8,14 +8,11 @@ - name: Check out code uses: actions/checkout@v1 - - name: Install Mbed TLS - run: brew install mbedtls - - name: Install ninja run: brew install ninja - name: Configure - run: mkdir build && cd build && cmake -G Ninja -DNNG_ENABLE_TLS=ON .. + run: mkdir build && cd build && cmake -G Ninja .. - name: build run: cd build && ninja diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/docs/man/nng_pipe_get.3.adoc new/nng-1.12.0/docs/man/nng_pipe_get.3.adoc --- old/nng-1.11/docs/man/nng_pipe_get.3.adoc 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/docs/man/nng_pipe_get.3.adoc 2026-06-09 23:32:43.000000000 +0200 @@ -131,6 +131,7 @@ [horizontal] `NNG_EBADTYPE`:: Incorrect type for option. `NNG_ECLOSED`:: Parameter _p_ does not refer to an open pipe. +`NNG_ENOENT`:: Parameter _p_ does not refer to an existing pipe. `NNG_ENOTSUP`:: The option _opt_ is not supported. `NNG_ENOMEM`:: Insufficient memory exists. `NNG_EINVAL`:: Size of destination _val_ too small for object. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/core/aio.c new/nng-1.12.0/src/core/aio.c --- old/nng-1.11/src/core/aio.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/core/aio.c 2026-06-09 23:32:43.000000000 +0200 @@ -9,6 +9,8 @@ // #include "core/nng_impl.h" + +#include <limits.h> #include <string.h> struct nni_aio_expire_q { @@ -201,8 +203,6 @@ if (fn != NULL) { fn(aio, arg, NNG_ECANCELED); - } else { - nni_task_abort(&aio->a_task); } nni_aio_wait(aio); @@ -228,8 +228,6 @@ if (fn != NULL) { fn(aio, arg, NNG_ECLOSED); - } else { - nni_task_abort(&aio->a_task); } } } @@ -347,6 +345,7 @@ aio->a_result = 0; aio->a_count = 0; aio->a_cancel_fn = NULL; + aio->a_abort = false; // We should not reschedule anything at this point. if (aio->a_stop) { @@ -373,7 +372,6 @@ // Convert the relative timeout to an absolute timeout. switch (aio->a_timeout) { case NNG_DURATION_ZERO: - nni_task_abort(&aio->a_task); return (NNG_ETIMEDOUT); case NNG_DURATION_INFINITE: case NNG_DURATION_DEFAULT: @@ -386,8 +384,13 @@ } nni_mtx_lock(&eq->eq_mtx); + if (aio->a_abort) { + int rv = aio->a_result; + nni_mtx_unlock(&eq->eq_mtx); + return (rv); + } + if (aio->a_stop) { - nni_task_abort(&aio->a_task); nni_mtx_unlock(&eq->eq_mtx); return (NNG_ECLOSED); } @@ -420,13 +423,17 @@ arg = aio->a_cancel_arg; aio->a_cancel_fn = NULL; aio->a_cancel_arg = NULL; + if (fn == NULL) { + // We haven't been scheduled yet, + // so make sure that the schedule will abort. + aio->a_abort = true; + aio->a_result = rv; + } nni_mtx_unlock(&eq->eq_mtx); // Stop any I/O at the provider level. if (fn != NULL) { fn(aio, arg, rv); - } else { - nni_task_abort(&aio->a_task); } } @@ -704,6 +711,19 @@ return (residual); } +bool +nni_aio_iov_clamp_len(size_t *len, size_t *count) +{ + NNI_ASSERT(*count <= (size_t) INT_MAX); + size_t headroom = (size_t) INT_MAX - *count; + bool clamped = *len > headroom; + if (clamped) { + *len = headroom; + } + *count += *len; + return clamped; +} + size_t nni_aio_iov_advance(nni_aio *aio, size_t n) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/core/aio.h new/nng-1.12.0/src/core/aio.h --- old/nng-1.11/src/core/aio.h 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/core/aio.h 2026-06-09 23:32:43.000000000 +0200 @@ -148,6 +148,14 @@ // nni_aio_iov_count returns the number of bytes referenced by the aio iov. extern size_t nni_aio_iov_count(nni_aio *); +// nni_aio_iov_clamp_len clamps *len so *count + *len does not exceed +// INT_MAX, adds *len to *count, and returns true if *len was reduced. +// Used when building platform iov lists whose cumulative byte count must +// not exceed INT_MAX (XNU sendmsg/readv, Windows WSABUF); callers should +// stop appending entries on a true return. Caller must seed *count to +// a value <= INT_MAX (typically 0). +extern bool nni_aio_iov_clamp_len(size_t *len, size_t *count); + extern int nni_aio_set_iov(nni_aio *, unsigned, const nni_iov *); extern void nni_aio_set_timeout(nni_aio *, nng_duration); @@ -214,6 +222,7 @@ bool a_expire_ok; // Expire from sleep is ok bool a_expiring; // Expiration in progress bool a_use_expire; // Use expire instead of timeout + bool a_abort; // Abort the operation. nni_task a_task; // Read/write operations. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/CMakeLists.txt new/nng-1.12.0/src/platform/CMakeLists.txt --- old/nng-1.11/src/platform/CMakeLists.txt 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/platform/CMakeLists.txt 2026-06-09 23:32:43.000000000 +0200 @@ -16,3 +16,5 @@ nng_test(platform_test) nng_test(resolver_test) nng_test(udp_test) +nng_test(tcp_stream_test) +nng_test(ipc_stream_test) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/ipc_stream_test.c new/nng-1.12.0/src/platform/ipc_stream_test.c --- old/nng-1.11/src/platform/ipc_stream_test.c 1970-01-01 01:00:00.000000000 +0100 +++ new/nng-1.12.0/src/platform/ipc_stream_test.c 2026-06-09 23:32:43.000000000 +0200 @@ -0,0 +1,106 @@ +// +// Copyright 2026 Staysail Systems, Inc. <[email protected]> +// +// 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 <limits.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include <nng/nng.h> + +#include <nuts.h> + +// Verifies the platform iov clamp handles cumulative iov totals exceeding +// INT_MAX without triggering EINVAL (macOS/XNU sendmsg). We build an +// oversized iov cheaply by referencing a single chunk 8 times; peak memory +// stays at ~256 MiB. Not meaningful on Windows: named-pipe IPC uses +// WriteFile (no scatter/gather) and already clamps writes to 16 MiB. +void +test_ipc_stream_iov_exceeds_int_max(void) +{ +#ifndef NNG_PLATFORM_POSIX + // Not POSIX: named-pipe IPC uses WriteFile (no scatter/gather). +#elif SIZE_MAX <= UINT32_MAX + // Requires 64-bit size_t. +#else + nng_stream_dialer *d = NULL; + nng_stream_listener *l = NULL; + char *url; + nng_aio *daio = NULL; + nng_aio *laio = NULL; + nng_aio *saio = NULL; + nng_stream *c1 = NULL; + nng_stream *c2 = NULL; + + NUTS_ADDR(url, "ipc"); + NUTS_PASS(nng_aio_alloc(&daio, NULL, NULL)); + NUTS_PASS(nng_aio_alloc(&laio, NULL, NULL)); + NUTS_PASS(nng_aio_alloc(&saio, NULL, NULL)); + + NUTS_PASS(nng_stream_listener_alloc(&l, url)); + NUTS_PASS(nng_stream_listener_listen(l)); + + NUTS_PASS(nng_stream_dialer_alloc(&d, url)); + nng_stream_dialer_dial(d, daio); + nng_stream_listener_accept(l, laio); + + nng_aio_wait(daio); + NUTS_PASS(nng_aio_result(daio)); + nng_aio_wait(laio); + NUTS_PASS(nng_aio_result(laio)); + + c1 = nng_aio_get_output(daio, 0); + c2 = nng_aio_get_output(laio, 0); + + // 8 x (INT_MAX/8 + 1) = INT_MAX + 1: cumulative iov just clears the + // 32-bit signed kernel cap while committing only ~256 MiB of memory. + const size_t per = ((size_t) INT_MAX / 8) + 1; + char *buf = malloc(per); + NUTS_ASSERT(buf != NULL); + memset(buf, 'A', per); + + nng_iov iov[8]; + for (int i = 0; i < 8; i++) { + iov[i].iov_buf = buf; + iov[i].iov_len = per; + } + NUTS_PASS(nng_aio_set_iov(saio, 8, iov)); + + // The peer never drains, so guard against any hang in the first + // sendmsg by bounding the wait. Normal completion is sub-second. + nng_aio_set_timeout(saio, 10000); + nng_stream_send(c1, saio); + nng_aio_wait(saio); + + // sendmsg only moves what fits in SO_SNDBUF, but it must not fail. + // Before the fix, macOS rejected the oversized iov with EINVAL. + NUTS_PASS(nng_aio_result(saio)); + NUTS_TRUE(nng_aio_count(saio) > 0); + NUTS_TRUE(nng_aio_count(saio) <= (size_t) INT_MAX); + + free(buf); + nng_aio_free(saio); + nng_aio_free(daio); + nng_aio_free(laio); + nng_stream_listener_close(l); + nng_stream_dialer_close(d); + nng_stream_listener_free(l); + nng_stream_dialer_free(d); + nng_stream_close(c1); + nng_stream_free(c1); + nng_stream_close(c2); + nng_stream_free(c2); +#endif +} + +NUTS_TESTS = { + { "ipc stream iov exceeds INT_MAX", + test_ipc_stream_iov_exceeds_int_max }, + { NULL, NULL }, +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/posix/posix_ipcconn.c new/nng-1.12.0/src/platform/posix/posix_ipcconn.c --- old/nng-1.11/src/platform/posix/posix_ipcconn.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/platform/posix/posix_ipcconn.c 2026-06-09 23:32:43.000000000 +0200 @@ -56,10 +56,14 @@ continue; } - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len > 0) { - iovec[niov].iov_len = aiov[i].iov_len; iovec[niov].iov_base = aiov[i].iov_buf; + iovec[niov].iov_len = aiov[i].iov_len; + clamped = nni_aio_iov_clamp_len( + &iovec[niov].iov_len, &count); niov++; } } @@ -121,10 +125,14 @@ nni_aio_finish_error(aio, NNG_EINVAL); continue; } - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len != 0) { - iovec[niov].iov_len = aiov[i].iov_len; iovec[niov].iov_base = aiov[i].iov_buf; + iovec[niov].iov_len = aiov[i].iov_len; + clamped = nni_aio_iov_clamp_len( + &iovec[niov].iov_len, &count); niov++; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/posix/posix_tcpconn.c new/nng-1.12.0/src/platform/posix/posix_tcpconn.c --- old/nng-1.11/src/platform/posix/posix_tcpconn.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/platform/posix/posix_tcpconn.c 2026-06-09 23:32:43.000000000 +0200 @@ -55,10 +55,14 @@ continue; } - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len > 0) { - iovec[niov].iov_len = aiov[i].iov_len; iovec[niov].iov_base = aiov[i].iov_buf; + iovec[niov].iov_len = aiov[i].iov_len; + clamped = nni_aio_iov_clamp_len( + &iovec[niov].iov_len, &count); niov++; } } @@ -120,10 +124,14 @@ nni_aio_finish_error(aio, NNG_EINVAL); continue; } - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len != 0) { - iovec[niov].iov_len = aiov[i].iov_len; iovec[niov].iov_base = aiov[i].iov_buf; + iovec[niov].iov_len = aiov[i].iov_len; + clamped = nni_aio_iov_clamp_len( + &iovec[niov].iov_len, &count); niov++; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/tcp_stream_test.c new/nng-1.12.0/src/platform/tcp_stream_test.c --- old/nng-1.11/src/platform/tcp_stream_test.c 1970-01-01 01:00:00.000000000 +0100 +++ new/nng-1.12.0/src/platform/tcp_stream_test.c 2026-06-09 23:32:43.000000000 +0200 @@ -0,0 +1,104 @@ +// +// Copyright 2026 Staysail Systems, Inc. <[email protected]> +// +// 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 <limits.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <nng/nng.h> + +#include <nuts.h> + +// Verifies the platform iov clamp handles cumulative iov totals exceeding +// INT_MAX without triggering EINVAL (macOS/XNU sendmsg). We build an +// oversized iov cheaply by referencing a single chunk 8 times; peak memory +// stays at ~256 MiB. +void +test_tcp_stream_iov_exceeds_int_max(void) +{ +#if SIZE_MAX <= UINT32_MAX + // Requires 64-bit size_t. +#else + nng_stream_dialer *d = NULL; + nng_stream_listener *l = NULL; + nng_aio *daio = NULL; + nng_aio *laio = NULL; + nng_aio *saio = NULL; + nng_stream *c1 = NULL; + nng_stream *c2 = NULL; + int port; + + NUTS_PASS(nng_aio_alloc(&daio, NULL, NULL)); + NUTS_PASS(nng_aio_alloc(&laio, NULL, NULL)); + NUTS_PASS(nng_aio_alloc(&saio, NULL, NULL)); + + NUTS_PASS(nng_stream_listener_alloc(&l, "tcp://127.0.0.1")); + NUTS_PASS(nng_stream_listener_listen(l)); + NUTS_PASS( + nng_stream_listener_get_int(l, NNG_OPT_TCP_BOUND_PORT, &port)); + + char uri[64]; + snprintf(uri, sizeof(uri), "tcp://127.0.0.1:%d", port); + + NUTS_PASS(nng_stream_dialer_alloc(&d, uri)); + nng_stream_dialer_dial(d, daio); + nng_stream_listener_accept(l, laio); + nng_aio_wait(daio); + NUTS_PASS(nng_aio_result(daio)); + nng_aio_wait(laio); + NUTS_PASS(nng_aio_result(laio)); + c1 = nng_aio_get_output(daio, 0); + c2 = nng_aio_get_output(laio, 0); + + // 8 x (INT_MAX/8 + 1) = INT_MAX + 1: cumulative iov just clears the + // 32-bit signed kernel cap while committing only ~256 MiB of memory. + const size_t per = ((size_t) INT_MAX / 8) + 1; + char *buf = malloc(per); + NUTS_ASSERT(buf != NULL); + memset(buf, 'A', per); + + nng_iov iov[8]; + for (int i = 0; i < 8; i++) { + iov[i].iov_buf = buf; + iov[i].iov_len = per; + } + NUTS_PASS(nng_aio_set_iov(saio, 8, iov)); + + // The peer never drains, so guard against any hang in the first + // sendmsg by bounding the wait. Normal completion is sub-second. + nng_aio_set_timeout(saio, 10000); + nng_stream_send(c1, saio); + nng_aio_wait(saio); + + // sendmsg only moves what fits in SO_SNDBUF, but it must not fail. + // Before the fix, macOS rejected the oversized iov with EINVAL. + NUTS_PASS(nng_aio_result(saio)); + NUTS_TRUE(nng_aio_count(saio) > 0); + NUTS_TRUE(nng_aio_count(saio) <= (size_t) INT_MAX); + + free(buf); + nng_aio_free(saio); + nng_aio_free(daio); + nng_aio_free(laio); + nng_stream_close(c1); + nng_stream_close(c2); + nng_stream_free(c1); + nng_stream_free(c2); + nng_stream_dialer_free(d); + nng_stream_listener_free(l); +#endif +} + +NUTS_TESTS = { + { "tcp stream iov exceeds INT_MAX", + test_tcp_stream_iov_exceeds_int_max }, + { NULL, NULL }, +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/platform/windows/win_tcpconn.c new/nng-1.12.0/src/platform/windows/win_tcpconn.c --- old/nng-1.11/src/platform/windows/win_tcpconn.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/platform/windows/win_tcpconn.c 2026-06-09 23:32:43.000000000 +0200 @@ -40,10 +40,15 @@ nni_aio_get_iov(aio, &naiov, &aiov); // Put the AIOs in Windows form. - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len != 0) { + size_t len = aiov[i].iov_len; + clamped = + nni_aio_iov_clamp_len(&len, &count); iov[niov].buf = aiov[i].iov_buf; - iov[niov].len = (ULONG) aiov[i].iov_len; + iov[niov].len = (ULONG) len; niov++; } } @@ -159,10 +164,15 @@ nni_aio_get_iov(aio, &naiov, &aiov); // Put the AIOs in Windows form. - for (niov = 0, i = 0; i < naiov; i++) { + size_t count = 0; + bool clamped = false; + for (niov = 0, i = 0; !clamped && i < naiov; i++) { if (aiov[i].iov_len != 0) { + size_t len = aiov[i].iov_len; + clamped = + nni_aio_iov_clamp_len(&len, &count); iov[niov].buf = aiov[i].iov_buf; - iov[niov].len = (ULONG) aiov[i].iov_len; + iov[niov].len = (ULONG) len; niov++; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/src/supplemental/http/http_server.c new/nng-1.12.0/src/supplemental/http/http_server.c --- old/nng-1.11/src/supplemental/http/http_server.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/src/supplemental/http/http_server.c 2026-06-09 23:32:43.000000000 +0200 @@ -1350,20 +1350,27 @@ { ".jpeg", "image/jpeg" }, { ".jpg", "image/jpeg" }, { ".js", "application/javascript" }, + { ".json", "application/json" }, { ".md", "text/markdown" }, { ".mp2", "video/mpeg" }, { ".mp3", "audio/mpeg3" }, + { ".mp4", "video/mp4" }, { ".mpeg", "video/mpeg" }, { ".mpg", "video/mpeg" }, { ".pdf", "application/pdf" }, { ".png", "image/png" }, { ".ps", "application/postscript" }, { ".rtf", "text/rtf" }, + { ".svg", "image/svg+xml" }, { ".text", "text/plain" }, { ".tif", "image/tiff" }, { ".tiff", "image/tiff" }, { ".txt", "text/plain" }, - { ".wav", "audio/wav"}, + { ".wasm", "application/wasm" }, + { ".wav", "audio/wav" }, + { ".webp", "image/webp" }, + { ".woff", "font/woff" }, + { ".woff2", "font/woff2" }, { "README", "text/plain" }, { NULL, NULL }, // clang-format on diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nng-1.11/tests/httpclient.c new/nng-1.12.0/tests/httpclient.c --- old/nng-1.11/tests/httpclient.c 2025-06-02 16:33:39.000000000 +0200 +++ new/nng-1.12.0/tests/httpclient.c 2026-06-09 23:32:43.000000000 +0200 @@ -26,24 +26,20 @@ #include "convey.h" #include "trantest.h" -const uint8_t example_sum[20] = { 0x4a, 0x3c, 0xe8, 0xee, 0x11, 0xe0, 0x91, - 0xdd, 0x79, 0x23, 0xf4, 0xd8, 0xc6, 0xe5, 0xb5, 0xe4, 0x1e, 0xc7, 0xc0, - 0x47 }; - const uint8_t chunked_sum[20] = { 0x9b, 0x06, 0xfb, 0xee, 0x51, 0xc6, 0x42, 0x69, 0x1c, 0xb3, 0xaa, 0x38, 0xce, 0xb8, 0x0b, 0x3a, 0xc8, 0x3b, 0x96, 0x68 }; TestMain("HTTP Client", { - Convey("Given a TCP connection to example.com", { - nng_aio * aio; + Convey("Given a TCP connection to httpbin.org", { + nng_aio *aio; nng_http_client *cli; - nng_http_conn * http; - nng_url * url; + nng_http_conn *http; + nng_url *url; So(nng_aio_alloc(&aio, NULL, NULL) == 0); - So(nng_url_parse(&url, "http://example.com/") == 0); + So(nng_url_parse(&url, "http://httpbin.org/") == 0); nng_aio_set_timeout(aio, 10000); So(nng_http_client_alloc(&cli, url) == 0); @@ -81,7 +77,7 @@ Convey("The message contents are correct", { uint8_t digest[20]; - void * data; + void *data; const char *cstr; size_t sz; nng_iov iov; @@ -106,17 +102,14 @@ nng_http_conn_read_all(http, aio); nng_aio_wait(aio); So(nng_aio_result(aio) == 0); - - nni_sha1(data, sz, digest); - So(memcmp(digest, example_sum, 20) == 0); }); }); }); Convey("Given a client", { - nng_aio * aio; + nng_aio *aio; nng_http_client *cli; - nng_url * url; + nng_url *url; So(nng_aio_alloc(&aio, NULL, NULL) == 0); @@ -134,7 +127,7 @@ Convey("One off exchange works", { nng_http_req *req; nng_http_res *res; - void * data; + void *data; size_t len; uint8_t digest[20]; @@ -150,15 +143,13 @@ So(nng_aio_result(aio) == 0); So(nng_http_res_get_status(res) == 200); nng_http_res_get_data(res, &data, &len); - nni_sha1(data, len, digest); - So(memcmp(digest, example_sum, 20) == 0); }); Convey("Connection reuse works", { - nng_http_req * req; - nng_http_res * res1; - nng_http_res * res2; - void * data; + nng_http_req *req; + nng_http_res *res1; + nng_http_res *res2; + void *data; size_t len; uint8_t digest[20]; nng_http_conn *conn = NULL; @@ -185,16 +176,12 @@ So(nng_aio_result(aio) == 0); So(nng_http_res_get_status(res1) == 200); nng_http_res_get_data(res1, &data, &len); - nni_sha1(data, len, digest); - So(memcmp(digest, example_sum, 20) == 0); nng_http_conn_transact(conn, req, res2, aio); nng_aio_wait(aio); So(nng_aio_result(aio) == 0); So(nng_http_res_get_status(res2) == 200); nng_http_res_get_data(res2, &data, &len); - nni_sha1(data, len, digest); - So(memcmp(digest, example_sum, 20) == 0); }); }); @@ -203,11 +190,11 @@ // are unavoidable in the infrastructure. We will revisit when we // provide our own HTTP test server on localhost. SkipConvey("Client times out", { - nng_aio * aio; + nng_aio *aio; nng_http_client *cli; - nng_url * url; - nng_http_req * req; - nng_http_res * res; + nng_url *url; + nng_http_req *req; + nng_http_res *res; So(nng_aio_alloc(&aio, NULL, NULL) == 0); @@ -234,9 +221,9 @@ }); Convey("Given a client (chunked)", { - nng_aio * aio; + nng_aio *aio; nng_http_client *cli; - nng_url * url; + nng_url *url; So(nng_aio_alloc(&aio, NULL, NULL) == 0); @@ -257,7 +244,7 @@ Convey("One off exchange works", { nng_http_req *req; nng_http_res *res; - void * data; + void *data; size_t len; uint8_t digest[20];
