Skip to content

feat: adds a simple Http library to Std#10478

Closed
algebraic-dev wants to merge 352 commits intosofia/async-futurefrom
sofia/async-http
Closed

feat: adds a simple Http library to Std#10478
algebraic-dev wants to merge 352 commits intosofia/async-futurefrom
sofia/async-http

Conversation

@algebraic-dev
Copy link
Member

This PR adds a simple Http library to Std.

@algebraic-dev algebraic-dev self-assigned this Sep 20, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 21, 2025
@ghost
Copy link

ghost commented Sep 21, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 4881c3042e8d205080b19779d8dedfc672da3cd0 --onto 4379002d0582ae96d7fc6ccf5921ff4e9aa7239e. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-21 22:08:49)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase eabd7309b74f13cc12d0ab03d4826f34e3e49c0d --onto 0807f73171ca8f765c11ef37d69fd95e6613a878. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-24 00:27:54)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5ef7b45afaedd794fb39b0fbd70924b573694a00 --onto ac0b82933f6eac9914011ca2caf38d0e4e991160. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-25 13:54:11)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 486d93c5fd4ec0e1735554f9143a66327ca3f5a9 --onto 54c6efea95a0d478f2659632749035962b1f4d8d. You can force Mathlib CI using the force-mathlib-ci label. (2025-10-07 18:22:48)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase aa86d95c0897a5aca9535dad6ffb1fd0f20cd5f1 --onto 14ff08db6f651775ead432d367b6b083878bb0f9. You can force Mathlib CI using the force-mathlib-ci label. (2025-10-14 17:00:51)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto 705084d9ba258dec704af428d7ce2444525f9ffb. You can force Mathlib CI using the force-mathlib-ci label. (2025-10-31 05:29:24)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto 1ce05b2a179eac8a902995c0caddc609c0169c49. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-01 17:03:01)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto de073706c5446208065c7479211a3737ff99af25. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-15 02:58:43)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto 5306a3469d20caa5f9d80384a5c1effdb14e9c67. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-23 06:25:53)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto b0e6db322421ce368999f08870fd747e45242f86. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-27 01:48:28)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 16508196e0dfa0702868333eecf6f6dc8b58d632 --onto a4f9a793d9bdf3f3d4b69f3ebcfa7cd347df9d1a. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-30 05:08:30)
  • ✅ Mathlib branch lean-pr-testing-10478 has successfully built against this PR. (2025-12-03 02:25:07) View Log
  • ✅ Mathlib branch lean-pr-testing-10478 has successfully built against this PR. (2025-12-03 06:06:32) View Log
  • ✅ Mathlib branch lean-pr-testing-10478 has successfully built against this PR. (2025-12-05 01:16:38) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 856825a4d2741f2de6d2d21454c20b1ba78b671b --onto 455fd0b4488e2adc85f825a52e2ee7d944a5740a. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-05 21:44:02)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase c9b8508f6b6868be1857d207edf9ac01d764f8d2 --onto 62f2f9229356039356c0469a46d8ecd77be88e2a. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-09 00:41:29)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase c9b8508f6b6868be1857d207edf9ac01d764f8d2 --onto 19e1fe55f33a8aadc4243da32828b70a4b4677cc. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-11 19:12:14)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e2617903f81f2f9ffc6c0b7a06cc91678c546305 --onto 0708024c4649f11da1276d8b6d4345972a9dc57c. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-17 18:48:51)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto 0708024c4649f11da1276d8b6d4345972a9dc57c. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-18 01:05:39)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto 4e656ea8e9273833b7cb06c720bdefbb5b9dbc87. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-20 01:15:44)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto 13c88f960f40b7c163b99e742010bbbbdbe8bba7. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-24 01:43:46)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto b3b33e85d38317eca940e4a9653660e9f8b5682a. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-27 00:01:31)
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2025-12-29 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-10 00:04:12)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto e56351da7ae15673a5bc2b83e7fb70e1fbd988ca. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-12 19:29:29)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto 3dfd125337305c9de6ddcc7c0330c50f0e39fb8e. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-18 18:46:44)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto e9a1c9ef63d8e53803c16077f03e2dacd4a890bd. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-21 04:20:58)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto 9063adbd51334f68608bad14cd298e6315e718d4. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-21 19:23:55)

@leanprover-bot
Copy link
Collaborator

leanprover-bot commented Sep 21, 2025

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 4881c3042e8d205080b19779d8dedfc672da3cd0 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-21 22:08:50)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase eabd7309b74f13cc12d0ab03d4826f34e3e49c0d --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-24 00:27:56)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 5ef7b45afaedd794fb39b0fbd70924b573694a00 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-25 13:54:14)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 486d93c5fd4ec0e1735554f9143a66327ca3f5a9 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-10-07 18:22:50)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase aa86d95c0897a5aca9535dad6ffb1fd0f20cd5f1 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-10-14 17:00:53)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f9adafe54d5070acbd270643f71b8455ca8c8d68 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-10-31 05:29:25)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 16508196e0dfa0702868333eecf6f6dc8b58d632 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-11-30 05:08:31)
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-11-30 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-12-03 01:18:19)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 856825a4d2741f2de6d2d21454c20b1ba78b671b --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-12-05 21:44:03)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase c9b8508f6b6868be1857d207edf9ac01d764f8d2 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-12-09 00:41:30)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase c9b8508f6b6868be1857d207edf9ac01d764f8d2 --onto eee58f4506d28a14c9a171165f999445a0663d93. You can force reference manual CI using the force-manual-ci label. (2025-12-11 19:12:15)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase e2617903f81f2f9ffc6c0b7a06cc91678c546305 --onto 0708024c4649f11da1276d8b6d4345972a9dc57c. You can force reference manual CI using the force-manual-ci label. (2025-12-17 18:48:53)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto 0708024c4649f11da1276d8b6d4345972a9dc57c. You can force reference manual CI using the force-manual-ci label. (2025-12-18 01:05:41)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto f317e28d842bad09a6111e1f72dda8a2c0bdc3c5. You can force reference manual CI using the force-manual-ci label. (2025-12-24 01:43:48)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f21f8d96f97989d3a34148329a158e94b220314b --onto c0d5e8bc2c925bc2b60f18c929acf7d73ea9ecec. You can force reference manual CI using the force-manual-ci label. (2025-12-27 00:01:32)
  • ✅ Reference manual branch lean-pr-testing-10478 has successfully built against this PR. (2026-01-10 00:10:55) View Log
  • 🟡 Reference manual branch lean-pr-testing-10478 build against this PR didn't complete normally. (2026-01-10 00:11:53) View Log
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto d92cdae8e901d3d9686f8c0e88a0371379c49dff. You can force reference manual CI using the force-manual-ci label. (2026-01-12 19:29:31)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto 4af9cc05924d81e1d5dd35105fdce007c5bbc2e8. You can force reference manual CI using the force-manual-ci label. (2026-01-18 18:46:46)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 5bb7f37645c1bcd822993543b32b95c78107b33a --onto e9a1c9ef63d8e53803c16077f03e2dacd4a890bd. You can force reference manual CI using the force-manual-ci label. (2026-01-21 19:23:57)

@algebraic-dev algebraic-dev changed the base branch from sofia/async-streammap to sofia/async-cancellation-token September 22, 2025 22:18
@algebraic-dev algebraic-dev force-pushed the sofia/async-cancellation-token branch from dde6cfa to 380dae6 Compare September 24, 2025 23:52
Copy link
Member

@TwoFX TwoFX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some preliminary review for the "easy" part of the PR.

@algebraic-dev algebraic-dev force-pushed the sofia/async-cancellation-token branch 2 times, most recently from 8c47efc to 45e2368 Compare September 25, 2025 12:26
@TwoFX
Copy link
Member

TwoFX commented Sep 25, 2025

I don't have a full test case for this, but when I create a response like

    return Std.Http.Response.new
      |>.status .ok
      |>.binary ByteArray.empty

then I think the Content-Length header should be set to 0, but it seems to be missing.

@algebraic-dev algebraic-dev requested a review from TwoFX September 26, 2025 06:57
@TwoFX
Copy link
Member

TwoFX commented Sep 26, 2025

It seems to me that there are some problems with timeouts around keep-alive.

I have this super simple server:

import Std.Internal.Http

def main : IO Unit := do
  (Std.Http.Server.serve (Std.Net.SocketAddress.v6 ⟨.ofParts 0 0 0 0 0 0 0 0, 8007⟩) (fun _ => pure <| .ok "hi")).block

Then I have this script:

#!/bin/bash

while true; do
  printf "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"
  sleep 2
done

When I run the server and do ./print.sh | nc localhost 8007, I expect the server to reply with hi every two seconds until the maximum number of requests is reached, and then I guess netcat should complain that the connection is closed. Instead, the server just seems to hang after the first request. It looks like it runs into the timeout (which is 1000 milliseconds by default), and then the Connection.handle function exists and the connection just... stays open in limbo.

This also reproduces in a browser. If I open localhost:8007, wait two seconds, and press F5, then the page will load indefinitely.

This seems to highlight several problems:

  • the request timeout starts too early, before the next request is even sent
  • the timeout is handled incorrectly
  • on a more basic level: it sounds problematic that we keep-alive connections only by number of requests, not by time. If a connection is used only once, it will stay open on the server for a potentially unbounded time. This last one might be acceptable because presumably a reverse proxy will timeout the connection after a while.

@algebraic-dev
Copy link
Member Author

It's probably a problem with the Timer API, the interaction with Selectable and the reference counting. I'm not sure how to fix this right now but I have a solution that changes a lot of stuff in the timer api :S

@algebraic-dev algebraic-dev force-pushed the sofia/async-cancellation-token branch from 60aeda4 to 4ac2b87 Compare October 7, 2025 01:41
@algebraic-dev algebraic-dev changed the base branch from sofia/async-cancellation-token to master October 7, 2025 15:03
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Jan 10, 2026
@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Jan 10, 2026
@github-actions github-actions bot removed the changes-stage0 Contains stage0 changes, merge manually using rebase label Jan 12, 2026
@algebraic-dev
Copy link
Member Author

Closed because its several PRs right now

feat: add core HTTP data types #12126
feat: introduce Headers data type for HTTP #12127
feat: introduce URI data type for HTTP #12128
feat: introduce Body type class and some Body types for HTTP #12144
feat: introduce HTTP/1.1 protocol state machine #12146
feat: introduce HTTP/1.1 server #12151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants