Skip to content

Add send_tree and dispatch_tree to support sending iodata - #59

Open
JonasGruenwald wants to merge 1 commit into
gleam-lang:mainfrom
JonasGruenwald:patch-1
Open

JonasGruenwald wants to merge 1 commit into
gleam-lang:mainfrom
JonasGruenwald:patch-1

Conversation

@JonasGruenwald

@JonasGruenwald JonasGruenwald commented Mar 15, 2026 •

Copy link
Copy Markdown

Closes: #58

I can rewrite the test if #57 is merged before this. (Tests have been adjusted)

@jtdowney jtdowney left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As you said, the mock HTTP server for tests was merged in #57. I would recommend rebasing and using it for the test.

Comment thread src/gleam/httpc.gleam Outdated
/// Send a HTTP request of binary data using the default configuration.
///
/// If you wish to use some other configuration use `dispatch_bits` instead.
/// If you wish to use some other configuration use `dispatch_tree` instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this method is for sending a BitArray, I'd expect the docs to poing to dispatch_bits if the configuration is needed.

Comment thread src/gleam/httpc.gleam Outdated
/// Send a HTTP request of binary data with the `BytesTree` type using the default configuration.
///
pub fn dispatch_bits(
/// If you wish to use some other configuration use `dispatch_bits` instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd expect this one to point to dispatch_tree.

Comment thread test/gleam_httpc_test.gleam Outdated
pub fn bytes_tree_test() {
let body =
string_tree.new()
|> string_tree.append("Hello")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use bytes_stree.append_string here and avoid the conversion at the end by starting with a BytesTree.

Comment thread CHANGELOG.md Outdated
@@ -1,5 +1,9 @@
# Changelog

## v5.1.0 - 2026-??-??

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should probably be in a section called Unreleased.

@JonasGruenwald

Copy link
Copy Markdown
Author

@jtdowney thanks for having a look!
I've rebased, changed it to use the mock server and gone through your comments :) mind having another look?

Comment thread src/gleam/httpc.gleam Outdated

/// Configuration that can be used to send HTTP requests.
///
/// To be used with `dispatch` and `dispatch_bits`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nit, but this doc should be updated to reference dispatch_tree.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah true, good point, I've added it

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sending string_tree / bytes_tree as body

2 participants