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

fix(http server): handle post and option HTTP requests properly. #637

Merged
merged 19 commits into from
Jan 5, 2022

Conversation

niklasad1
Copy link
Member

Partly fixes #628

@niklasad1 niklasad1 requested a review from a team as a code owner January 4, 2022 12:39
http-server/src/response.rs Outdated Show resolved Hide resolved
http-server/src/server.rs Outdated Show resolved Hide resolved
http-server/src/server.rs Outdated Show resolved Hide resolved
@@ -302,116 +302,25 @@ impl<M: Middleware> Server<M> {
// two cases: a single RPC request or a batch of RPC requests.
async move {
if let Err(e) = access_control_is_valid(&access_control, &request) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this became hard to review, however validate origins and headers before checking the method kind.

@@ -469,3 +375,110 @@ fn is_json(content_type: Option<&hyper::header::HeaderValue>) -> bool {
_ => false,
}
}

/// Process a verified request, it implies a POST request with content type JSON.
async fn process_validated_request(
Copy link
Member Author

Choose a reason for hiding this comment

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

move to a separate function to decrease the indentation level and become more readable...

@niklasad1 niklasad1 changed the title fix(http server): handle post and option requests. fix(http server): handle post and option HTTP requests properly. Jan 4, 2022
Copy link
Contributor

@maciejhirsz maciejhirsz left a comment

Choose a reason for hiding this comment

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

Nice!

examples/cors_server.rs Outdated Show resolved Hide resolved
@niklasad1 niklasad1 merged commit 6f99a03 into master Jan 5, 2022
@niklasad1 niklasad1 deleted the na-fix-http-server-options-method branch January 5, 2022 15:01
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.

how can i retun a custom response header?
4 participants