Skip to content

Commit 129c5a3

Browse files
ashtumlouistatta
authored andcommitted
Mohammad's Q3 2024 update
1 parent 84f8f9b commit 129c5a3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout: post
3+
nav-class: dark
4+
categories: mohammad
5+
title: Boost.Http.Proto Project Highlights
6+
author-id: mohammad
7+
---
8+
9+
Here’s a look at some recent projects I've been focusing on:
10+
11+
### Boost.Http.Proto
12+
13+
#### Parsing Chunked Bodies
14+
15+
The `http_proto::parser` uses a circular buffer internally, which sometimes causes HTTP message bodies to span across two buffers. Previously, this required copying data into a temporary buffer for chunked parsing, ensuring continuous memory access. To address this, I introduced a `chained_sequence` abstraction, which lets two buffers appear as a single, contiguous buffer without the need for copying. This approach streamlines the parser implementation and improves efficiency by reducing memory operations. Iterating over `chained_sequence` is nearly as fast as iterating over a single range because it requires only a single comparison per iteration.
16+
17+
#### gzip/deflate Support
18+
19+
One goal for `Http.Proto` is to offer optional support for compression algorithms like gzip, deflate, and brotli, keeping dependencies optional. This allows flexibility, as users may not need compression or might lack libraries like Zlib on their platform. To enable this, we introduced an optional Zlib interface within `http_proto`, allowing gzip/deflate support in `http_proto::parser` without mandatory linking. Now, the parser can read the `Content-Encoding` field and apply the necessary decoding if a suitable compression service is available.
20+
21+
### Boost.Http.Io
22+
23+
Following updates in `Http.Proto`, I refactored the [C++20 coroutine client example](https://github.com/cppalliance/http_io/blob/develop/example/client/flex_await) in `Http.Io`. The client now requests with `Accept-Encoding: gzip, deflate` and decodes responses accordingly. It also includes basic redirect support and streams the response body piece by piece to standard output, allowing it to handle large file downloads.
24+
25+
### Boost.Beast
26+
27+
Alongside routine bug fixes and responses to user-reported issues, here are a few notable changes in the Boost.Beast project:
28+
29+
- **`beast::basic_parser` Enhancement**: A new `trailer_fields` state was added for parsing trailer fields in chunked HTTP message bodies. This state respects user-defined `header_limit` settings and provides appropriate error messages when limits are exceeded.
30+
- **Error Handling in `basic_fields`**: `basic_fields` interfaces now include an overload that accepts a `system::error_code` instead of throwing exceptions. This enables parsers to report insertion errors directly to the caller.
31+
- **`skip_` Variable Removal**: The parser previously used a state variable `skip_` to track parsed characters in `CRLF` processing within chunk headers. Benchmarks showed that removing `skip_` improves performance, as the parser can find `CRLF` directly within the buffer. This change has also simplified the parser's implementation.
32+
- **Forward-Declared Headers for `beast::http`**: New forward-declared headers are now available for all types in the `beast::http` namespace, enabling users to separate implementation and usage sites more effectively by including only the necessary `*_fwd` headers.

0 commit comments

Comments
 (0)