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>
|
#include <jansson.h>
|
||||||
|
|
||||||
|
#define NGHTTP2_NO_SSIZE_T
|
||||||
#include <nghttp2/nghttp2.h>
|
#include <nghttp2/nghttp2.h>
|
||||||
|
|
||||||
#include "template.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,
|
static void deflate_hd(nghttp2_hd_deflater *deflater,
|
||||||
const std::vector<nghttp2_nv> &nva, size_t inputlen,
|
const std::vector<nghttp2_nv> &nva, size_t inputlen,
|
||||||
int seq) {
|
int seq) {
|
||||||
ssize_t rv;
|
|
||||||
std::array<uint8_t, 64_k> buf;
|
std::array<uint8_t, 64_k> buf;
|
||||||
|
|
||||||
rv = nghttp2_hd_deflate_hd(deflater, buf.data(), buf.size(),
|
auto rv = nghttp2_hd_deflate_hd2(deflater, buf.data(), buf.size(),
|
||||||
(nghttp2_nv *)nva.data(), nva.size());
|
(nghttp2_nv *)nva.data(), nva.size());
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
|
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
|
#define NGHTTP2_NO_SSIZE_T
|
||||||
#include <nghttp2/nghttp2.h>
|
#include <nghttp2/nghttp2.h>
|
||||||
|
|
||||||
#include "template.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) {
|
static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
|
||||||
ssize_t rv;
|
|
||||||
nghttp2_nv nv;
|
nghttp2_nv nv;
|
||||||
int inflate_flags;
|
int inflate_flags;
|
||||||
size_t old_settings_table_size =
|
size_t old_settings_table_size =
|
||||||
@@ -120,8 +120,8 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
|
|||||||
seq);
|
seq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rv = nghttp2_hd_inflate_change_table_size(inflater,
|
auto rv = nghttp2_hd_inflate_change_table_size(
|
||||||
json_integer_value(table_size));
|
inflater, json_integer_value(table_size));
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"nghttp2_hd_change_table_size() failed with error %s at %d\n",
|
"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();
|
auto p = buf.data();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
inflate_flags = 0;
|
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) {
|
if (rv < 0) {
|
||||||
fprintf(stderr, "inflate failed with error code %zd at %d\n", rv, seq);
|
fprintf(stderr, "inflate failed with error code %zd at %d\n", rv, seq);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|||||||
Reference in New Issue
Block a user