mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-06 18:18:52 +08:00
deflatehd, inflatehd: Migrate to nghttp2_ssize API
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#define NGHTTP2_NO_SSIZE_T
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
#include "template.h"
|
||||
@@ -113,11 +114,10 @@ static void output_to_json(nghttp2_hd_deflater *deflater, const uint8_t *buf,
|
||||
static void deflate_hd(nghttp2_hd_deflater *deflater,
|
||||
const std::vector<nghttp2_nv> &nva, size_t inputlen,
|
||||
int seq) {
|
||||
ssize_t rv;
|
||||
std::array<uint8_t, 64_k> buf;
|
||||
|
||||
rv = nghttp2_hd_deflate_hd(deflater, buf.data(), buf.size(),
|
||||
(nghttp2_nv *)nva.data(), nva.size());
|
||||
auto rv = nghttp2_hd_deflate_hd2(deflater, buf.data(), buf.size(),
|
||||
(nghttp2_nv *)nva.data(), nva.size());
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#define NGHTTP2_NO_SSIZE_T
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
#include "template.h"
|
||||
@@ -93,7 +94,6 @@ static void to_json(nghttp2_hd_inflater *inflater, json_t *headers,
|
||||
}
|
||||
|
||||
static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
|
||||
ssize_t rv;
|
||||
nghttp2_nv nv;
|
||||
int inflate_flags;
|
||||
size_t old_settings_table_size =
|
||||
@@ -120,8 +120,8 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
|
||||
seq);
|
||||
return -1;
|
||||
}
|
||||
rv = nghttp2_hd_inflate_change_table_size(inflater,
|
||||
json_integer_value(table_size));
|
||||
auto rv = nghttp2_hd_inflate_change_table_size(
|
||||
inflater, json_integer_value(table_size));
|
||||
if (rv != 0) {
|
||||
fprintf(stderr,
|
||||
"nghttp2_hd_change_table_size() failed with error %s at %d\n",
|
||||
@@ -147,7 +147,8 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
|
||||
auto p = buf.data();
|
||||
for (;;) {
|
||||
inflate_flags = 0;
|
||||
rv = nghttp2_hd_inflate_hd(inflater, &nv, &inflate_flags, p, buflen, 1);
|
||||
auto rv =
|
||||
nghttp2_hd_inflate_hd3(inflater, &nv, &inflate_flags, p, buflen, 1);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "inflate failed with error code %zd at %d\n", rv, seq);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
Reference in New Issue
Block a user