barehttp 0.1.0

Blocking HTTP/1.1 client for no_std + alloc
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
name: CI

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions: {}

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -D warnings
  # Pinned so install-action cache keys stay stable across runs.
  NEXTEST_VERSION: "0.9.140"
  CARGO_FUZZ_VERSION: "0.13.2"
  LLVM_COV_VERSION: "0.8.7"
  CARGO_DENY_VERSION: "0.20.2"
  FUZZ_MAX_TOTAL_TIME: "60"
  # Coverage fail-under (% lines). Functions/regions: coverage_baseline.toml / CONTRIBUTING.md.
  COVERAGE_FAIL_UNDER: "70"

jobs:
  features:
    name: Features (${{ matrix.name }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: none
            args: --no-default-features
          - name: cookie-jar
            args: --no-default-features --features cookie-jar
          - name: gzip
            args: --no-default-features --features gzip
          - name: zstd
            args: --no-default-features --features zstd
          - name: all
            args: --all-features
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest@${{ env.NEXTEST_VERSION }}

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: features-${{ matrix.name }}

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Check
        run: cargo check --locked ${{ matrix.args }}

      - name: Clippy
        if: ${{ !cancelled() }}
        run: cargo clippy --locked --all-targets ${{ matrix.args }} -- -D warnings

      # Unit + integration (local mock server). Ignored httpbin tests stay skipped.
      - name: Test
        if: ${{ !cancelled() }}
        run: cargo nextest run --profile ci --locked ${{ matrix.args }}

  embedded:
    name: Embedded
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: thumbv7em-none-eabi

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Check
        run: |
          cargo check --locked --target thumbv7em-none-eabi --no-default-features
          cargo check --locked --target thumbv7em-none-eabi --features gzip

  miri:
    name: Miri
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install nightly + miri
        uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Miri (sync + focused)
        env:
          MIRIFLAGS: -Zmiri-strict-provenance
        run: |
          cargo miri setup
          cargo miri test --lib sync::
          cargo miri test --lib --features gzip gzip::
          cargo miri test --lib --features cookie-jar cookie_jar::

  fuzz:
    name: Fuzz
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install nightly
        uses: dtolnay/rust-toolchain@nightly

      # libfuzzer-sys links via clang; ubuntu-latest does not ship it by default.
      - name: Install clang
        run: sudo apt-get update && sudo apt-get install -y clang

      # Prebuilt via install-action/binstall; pin avoids rebuilding each run.
      - name: Install cargo-fuzz
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-fuzz@${{ env.CARGO_FUZZ_VERSION }}

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: fuzz -> target

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Cache fuzz corpora
        uses: actions/cache@v5
        with:
          path: |
            fuzz/corpus
            fuzz/artifacts
          key: fuzz-corpus-${{ runner.os }}-${{ hashFiles('fuzz/fuzz_targets/**', 'fuzz/Cargo.toml') }}
          restore-keys: |
            fuzz-corpus-${{ runner.os }}-

      # install-action cargo-fuzz is musl-built; default --target is
      # x86_64-unknown-linux-musl, which breaks -Zsanitizer=address. Pin GNU host.
      # Bounded runs only; longer campaigns stay in release.
      - name: Fuzz targets
        run: |
          mkdir -p fuzz/corpus fuzz/artifacts
          T="${{ env.FUZZ_MAX_TOTAL_TIME }}"
          cargo +nightly fuzz run --target x86_64-unknown-linux-gnu parse_response -- \
            -max_total_time="$T" -dict=fuzz/dictionaries/http.dict
          cargo +nightly fuzz run --target x86_64-unknown-linux-gnu parse_response_structured -- \
            -max_total_time="$T" -dict=fuzz/dictionaries/http.dict
          cargo +nightly fuzz run --target x86_64-unknown-linux-gnu parse_uri -- \
            -max_total_time="$T" -dict=fuzz/dictionaries/uri.dict
          cargo +nightly fuzz run --target x86_64-unknown-linux-gnu inflate_gzip -- \
            -max_total_time="$T" -dict=fuzz/dictionaries/gzip.dict

  deny:
    name: cargo-deny
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install cargo-deny
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-deny@${{ env.CARGO_DENY_VERSION }}

      - name: cargo deny check
        run: cargo deny check advisories licenses bans

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest@${{ env.NEXTEST_VERSION }}

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-llvm-cov@${{ env.LLVM_COV_VERSION }}

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: coverage

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Coverage (LCOV + Cobertura + HTML)
        run: bash scripts/coverage.sh

      - name: Upload coverage artifacts
        if: ${{ !cancelled() }}
        uses: actions/upload-artifact@v6
        with:
          name: coverage-${{ github.sha }}
          path: |
            target/llvm-cov/lcov.info
            target/llvm-cov/cobertura.xml
            target/llvm-cov/html
          if-no-files-found: error

  ui:
    name: API compile tests (trybuild)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: ui

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: trybuild / UI tests
        run: cargo test --locked --test ui

  stable:
    name: Stable checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Format
        run: cargo fmt --all -- --check

      - name: Docs
        if: ${{ !cancelled() }}
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --locked --no-deps --all-features

      - name: Examples
        if: ${{ !cancelled() }}
        run: cargo build --locked --examples --all-features

      - name: Lockfile
        if: ${{ !cancelled() }}
        run: cargo metadata --format-version 1 --locked >/dev/null

      - name: Available dependency updates
        if: ${{ !cancelled() }}
        run: cargo update --dry-run

      - name: Dependency tree
        if: ${{ !cancelled() }}
        run: cargo tree -e features --all-features

  # Compile all benches; run Callgrind with soft limits vs previous baseline in cache.
  # First run on a cold cache always passes; later runs fail on >5% Ir / >10% cycles.
  benches:
    name: Benches
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install Valgrind
        run: sudo apt-get update && sudo apt-get install -y valgrind

      - name: Install gungraun-runner
        uses: taiki-e/install-action@v2
        with:
          tool: gungraun-runner@0.19.4

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Cache Gungraun baselines
        uses: actions/cache@v5
        with:
          path: |
            target/gungraun
            .gungraun
          key: gungraun-${{ runner.os }}-${{ hashFiles('benches/**', 'src/**', 'Cargo.lock') }}
          restore-keys: |
            gungraun-${{ runner.os }}-

      - name: Compile all benches
        run: cargo bench --locked --no-run --all-features

      - name: Callgrind regression (soft limits)
        run: cargo bench --locked --bench gungraun_callgrind --all-features

      - name: Criterion smoke (compile + short run)
        run: |
          cargo bench --locked --bench criterion_hot_paths --all-features -- \
            --warm-up-time 0.2 --measurement-time 0.5 --sample-size 10
          cargo bench --locked --bench criterion_e2e --all-features -- \
            --warm-up-time 0.2 --measurement-time 0.5 --sample-size 10

      - name: dhat allocation smoke
        env:
          BAREHTTP_DHAT_ITERS: "5"
        run: |
          cargo bench --locked --bench dhat_parser --all-features
          cargo bench --locked --bench dhat_gzip --features gzip
          cargo bench --locked --bench dhat_e2e --all-features

  msrv:
    name: MSRV (1.90)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust 1.90
        uses: dtolnay/rust-toolchain@1.90

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest@${{ env.NEXTEST_VERSION }}

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Check (all features)
        run: cargo check --locked --all-features

      - name: Nextest (all features)
        run: cargo nextest run --profile ci --locked --all-features

  os-matrix:
    name: OS (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest@${{ env.NEXTEST_VERSION }}

      - name: Cache
        uses: Swatinem/rust-cache@v2

      - name: Quiet rust-cache trybuild ENOENT
        if: always()
        shell: bash
        # rust-cache cleans both nested dirs; creating only one makes the other ENOENT.
        run: mkdir -p target/tests/target target/tests/trybuild

      - name: Nextest (default / none)
        run: cargo nextest run --profile ci --locked --no-default-features

      - name: Nextest (all features)
        run: cargo nextest run --profile ci --locked --all-features