-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-135056: Add a --cors CLI argument to http.server #135057
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
Open
aisipos
wants to merge
12
commits into
python:main
Choose a base branch
from
aisipos:https-server-cors-issue-135056
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−6
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0d02fbe
gh-135056: Add a --cors CLI argument to http.server
aisipos 1838da7
gh-issue-135056: Fix doc versionchanged and NEWS entries.
aisipos a3256fd
gh-13056: Allow unspecified response_headers in HTTPServer.
aisipos 77b5fff
gh-135056: Simplifications and cleanups to http cors changes.
aisipos 5f89c97
gh-135056: Add a --header argument to http.server cli.
aisipos a3243fe
gh-135056: Remove --cors opt from http.server in favor of --header
aisipos b1026d2
gh-135056: Use response_headers only in SimpleHTTPRequestHandler
aisipos 6f88c13
gh-135056: Add test for http.server cli --header argument
aisipos 7a793f2
gh-135056: Support multiple headers of the same name.
aisipos 9450b86
gh-135056: Remove some commented out and unused code.
aisipos 5a30d91
gh-135056: Capitalize CLI acronym in the docs.
aisipos d317cc2
gh-135056: Simplify args.header processing.
aisipos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-135056: Add test for http.server cli --header argument
- Loading branch information
commit 6f88c13a4338dd33827e7cd929e7744ef63d3aca
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1487,6 +1487,34 @@ def test_unknown_flag(self, _): | |||||||||
self.assertEqual(stdout.getvalue(), '') | ||||||||||
self.assertIn('error', stderr.getvalue()) | ||||||||||
|
||||||||||
def test_response_headers_arg(self): | ||||||||||
# with mock.patch.object( | ||||||||||
# SimpleHTTPRequestHandler, '__init__' | ||||||||||
# ) as mock_handler, \ | ||||||||||
# mock.patch.object( | ||||||||||
# HTTPServer, 'serve_forever' | ||||||||||
# ) as mock_serve_forever: | ||||||||||
with mock.patch.object( | ||||||||||
HTTPServer, 'serve_forever' | ||||||||||
) as mock_serve_forever: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 9450b86 |
||||||||||
httpd = server._main( | ||||||||||
['-H', 'X-Test1', 'Test1', '-H', 'X-Test2', 'Test2', '8080'] | ||||||||||
) | ||||||||||
request_handler_class = httpd.RequestHandlerClass | ||||||||||
with mock.patch.object( | ||||||||||
request_handler_class, '__init__' | ||||||||||
) as mock_handler_init: | ||||||||||
mock_handler_init.return_value = None | ||||||||||
# finish_request instantiates a request handler class, | ||||||||||
# ensure response_headers are passed to it | ||||||||||
httpd.finish_request(mock.Mock(), '127.0.0.1') | ||||||||||
mock_handler_init.assert_called_once_with( | ||||||||||
mock.ANY, mock.ANY, mock.ANY, directory=mock.ANY, | ||||||||||
response_headers={ | ||||||||||
'X-Test1': 'Test1', 'X-Test2': 'Test2' | ||||||||||
} | ||||||||||
) | ||||||||||
|
||||||||||
|
||||||||||
class CommandLineRunTimeTestCase(unittest.TestCase): | ||||||||||
served_data = os.urandom(32) | ||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9450b86. Sorry to mistakenly leave these in my earlier checkins.