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

added TestServer::client_headers #2097

Merged
merged 6 commits into from
Apr 1, 2021

Conversation

sfisol
Copy link
Contributor

@sfisol sfisol commented Mar 20, 2021

PR Type

Feature (used in testing)

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

TestServer methods .ws() and .ws_at() disallow any altering of request they perform.

This PR adds .ws_at_with_config() method that takes a closure used for configuring the request.

This PR adds TestServer::client_headers method that exposes mutable headers of client used to perform requests. This allows to add custom headers.

For example, this allows to add authorization headers if WebSocket handler needs it.

Changes were added to both actix-web/src/test.rs and actix-http-test/src/lib.rs files

@sfisol sfisol force-pushed the feature/test_websocket_with_config branch from 8ff6829 to a3bc8c7 Compare March 20, 2021 09:53
@robjtede robjtede added A-test-server project: test-server A-web project: actix-web B-semver-minor labels Mar 20, 2021
@sfisol sfisol force-pushed the feature/test_websocket_with_config branch 3 times, most recently from 72949a2 to 0d451d2 Compare March 25, 2021 09:03
@robjtede robjtede requested review from a team March 25, 2021 09:07
@robjtede robjtede changed the title added TestServer::ws_at_with_config added TestServer::ws_at_with_config Mar 25, 2021
CHANGES.md Outdated Show resolved Hide resolved
@fakeshadow
Copy link
Contributor

fakeshadow commented Mar 25, 2021

It would be better to just expose headers field from awc::Client object.
TestServer object would be able to mutate it directly.

@sfisol sfisol force-pushed the feature/test_websocket_with_config branch from 0d451d2 to 820fb4c Compare March 25, 2021 09:56
@fakeshadow fakeshadow mentioned this pull request Mar 25, 2021
4 tasks
@sfisol sfisol force-pushed the feature/test_websocket_with_config branch from 820fb4c to 013b975 Compare March 31, 2021 09:51
@sfisol sfisol changed the title added TestServer::ws_at_with_config added TestServer::client_headers Mar 31, 2021
@sfisol
Copy link
Contributor Author

sfisol commented Mar 31, 2021

I rebased on #2114 and amended my changes to use mutable headers in TestServer's client.

@sfisol sfisol force-pushed the feature/test_websocket_with_config branch from 228b073 to b1ab4fe Compare March 31, 2021 17:39
@sfisol
Copy link
Contributor Author

sfisol commented Mar 31, 2021

@robjtede I've amended your last commit because somehow HeaderMap was still not imported.

@robjtede robjtede merged commit a807d33 into actix:master Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-test-server project: test-server A-web project: actix-web B-semver-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants