Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a HTTP body #139

Merged
merged 7 commits into from
Jan 26, 2021
Merged

Add support for a HTTP body #139

merged 7 commits into from
Jan 26, 2021

Conversation

PauloMelo
Copy link
Contributor

Hi emilk,

here is the PR.

Regards,
Paulo Melo

@emilk emilk changed the title There is no POST for http_fetch #137 Add support for a HTTP body Jan 26, 2021
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

This also needs to be implemented in egui_glium/src/http.rs

The CI wasn't configured to actually test the http feature, but that has now been fixed, so please rebase on latest master to get this PR tested by the CI.

Also: please test this manually with an actual HTTP request. I would assume most HTTP servers would also require a Content-Type header?

@@ -24,6 +24,10 @@ async fn fetch_jsvalue(request: &Request) -> Result<Response, JsValue> {
opts.method(method);
opts.mode(web_sys::RequestMode::Cors);

if method == &"POST".to_string() {
Copy link
Owner

Choose a reason for hiding this comment

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

method == "POST" should work fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tested manually with my personal development http server. I use kore from kore.io.
By default the Content-Type is plain/text. If we would send binary data then we need to change it, but since web_sys only has the body referenced by JsValue (and I am new to Rust - less than a week) I believe that we need only to send it if we want to change.

I the GLIUM version since it uses ureq it has the separate functions to send binary, text, form or json.

Copy link
Owner

Choose a reason for hiding this comment

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

I have tested manually with my personal development http server.

Great! Web or glium version or both?

I am new to Rust - less than a week

Wow! Good work on this PR, and welcome to the wonderful world of Rust!

egui_web/src/http.rs Outdated Show resolved Hide resolved
egui_web/src/http.rs Outdated Show resolved Hide resolved
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Starting to look good!

egui_glium/src/http.rs Outdated Show resolved Hide resolved
@emilk
Copy link
Owner

emilk commented Jan 26, 2021

well that last commit was meant to have a proper commit message 🙄 sorry about that :)

@emilk emilk merged commit eedb63b into emilk:master Jan 26, 2021
@emilk
Copy link
Owner

emilk commented Jan 26, 2021

Thank you!

@PauloMelo PauloMelo deleted the http_post branch January 26, 2021 20:48
@PauloMelo PauloMelo restored the http_post branch January 26, 2021 20:56
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.

2 participants