Commit Graph

341 Commits

Author SHA1 Message Date
Lagicrus
0fd08c6114 Update response.rst 2020-01-04 21:26:03 +00:00
Lagicrus
cd779b6e4f Update response.rst 2020-01-04 19:51:50 +00:00
Adam Hopkins
3f6a978328 Swap out requests-async for httpx (#1728)
* Begin swap of requests-async for httpx

* Finalize httpx adoption and resolve tests

Resolve linting and formatting

* Remove documentation references to requests-async in favor of httpx
2019-12-20 19:23:52 -08:00
Seonghyeon Kim
4c45d30400 FIX: invalid rst syntax (#1727) 2019-12-12 10:24:11 -06:00
Lagicrus
a4185a0ba7 Doc rework (#1698)
* blueprints

* class_based_views

* config

* decorators

* deploying

* exceptions

* extensions

* getting_started

* middleware

* request_data

* response

* routing

* static_files

* streaming

* testing

* versioning

* Fix bug and links

* spelling mistakes

* Bug fixes and minor tweaks

* Create 1691.doc.rst

* Bug fixes and tweaks

Co-Authored-By: Harsha Narayana <harsha2k4@gmail.com>
2019-11-14 14:11:38 -06:00
Harsha Narayana
e81a8ce073 fix SERVER_NAME enforcement in url_for and request.args documentation (#1708)
* 🐛 fix SERVER_NAME enforcement in url_for

fixes #1707

* 💡 add additional documentation for using request.args

fixes #1704

*  add additional test to check url_for without SERVER_NAME

* 📝 add changelog for fixes
2019-11-01 10:32:49 -07:00
Lagicrus
0df37fa653 Update websocket.rst (#1694) 2019-10-08 16:28:09 -07:00
L. Kärkkäinen
c54a8b10bb Implement dict-like API on request objects for custom data. (#1666)
* Implement dict-like API on request objects for custom data.
* Updated docs about custom_context.
2019-09-26 14:11:31 -07:00
Ashley Sommer
7674e917e4 Fixes "after_server_start" when using return_asyncio_server. (#1676)
* Fixes ability to trigger "after_server_start", "before_server_stop", "after_server_stop" server events when using app.create_server to start your own asyncio_server
See example file run_async_advanced for a full example

* Fix a missing method on AsyncServer that some tests need
Add a tiny bit more documentation in-code
Change name of AsyncServerCoro to AsyncioServer
2019-09-16 10:59:16 -07:00
Lagicrus
b7d4121586 Update static_files.md (#1672) 2019-09-11 14:37:14 -07:00
L. Kärkkäinen
1e4b1c4d1a Forwarded headers and otherwise improved proxy handling (#1638)
* Added support for HTTP Forwarded header and combined parsing of other proxy headers.

- Accessible via request.forwarded that tries parse_forwarded and then parse_xforwarded
- parse_forwarded uses the Forwarded header, if config.FORWARDED_SECRET is provided and a matching header field is found
- parse_xforwarded uses X-Real-IP and X-Forwarded-* much alike the existing implementation
- This commit does not change existing request properties that still use the old code and won't make use of Forwarded headers.

* Use req.forwarded in req properties server_name, server_port, scheme and remote_addr.

X-Scheme handling moved to parse_xforwarded.

* Cleanup and fix req.server_port; no longer reports socket port if any forwards headers are used.

* Update docstrings to incidate that forwarded header is used first.

* Remove testing function.

* Fix tests and linting.

- One test removed due to change of semantics - no socket port will be used if any forwarded headers are in effect.
- Other tests augmented with X-Forwarded-For, to allow the header being tested take effect (shouldn't affect old implementation).

* Try to workaround buggy tools complaining about incorrect ordering of imports.

* Cleanup forwarded processing, add comments. secret is now also returned.

* Added tests, fixed quoted string handling, cleanup.

* Further tests for full coverage.

* Try'n make linter happy.

* Add support for multiple Forwarded headers. Unify parse_forwarded parameters with parse_xforwarded.

* Implement multiple headers support for X-Forwarded-For.

- Previously only the first header was used, so this BUGFIX may affect functionality.

* Bugfix for request.server_name: strip port and other parts.

- request.server_name docs claim that it returns the hostname only (no port).
- config.SERVER_NAME may be full URL, so strip scheme, port and path
- HTTP Host and consequently forwarded Host may include port number, so
  strip that also for forwarded hosts (previously only done for HTTP Host).
- Possible performance benefit of limiting to one split.

* Fallback to app.url_for and let it handle SERVER_NAME if defined (until a proper solution is implemented).

* Revise previous commit. Only fallback for full URL SERVER_NAMEs; allows host to be defined and proxied information still being used.

* Heil lintnazi.

* Modify testcase not to use underscores in URLs. Use hyphens which the spec allows for.

* Forwarded and Host header parsing improved.

- request.forwarded lowercases hosts, separates host:port into their own fields and lowercases addresses
- forwarded.parse_host helper function added and used for parsing all host-style headers (IPv6 cannot be simply split(":")).
- more tests fixed not to use underscores in hosts as those are no longer accepted and lead to the field being rejected

* Fixed typo in docstring.

* Added IPv6 address tests for Host header.

* Fix regex.

* Further tests and stricter forwarded handling.

* Fix merge commit

* Linter

* Linter

* Linter

* Add  to avoid re-using the  variable. Make a few raw strings non-raw.

* Remove unnecessary or

* Updated docs (work in progress).

* Enable REAL_IP_HEADER parsing irregardless of PROXIES_COUNT setting.

- Also cleanup and added comments

* New defaults for PROXIES_COUNT and REAL_IP_HEADER, updated tests.

* Remove support for PROXIES_COUNT=-1.

* Linter errors.

- This is getting ridiculous: cannot fit an URL on one line, linter requires
  splitting the string literal!

* Add support for by=_proxySecret, updated docs, updated tests.

* Forwarded headers' semantics tuning.

- Forwarded host is now preserved in original format
- request.host now returns a forwarded host if available, else the Host header
- Forwarded options are preserved in original order, and later keys override earlier ones
- Forwarded path is automatically URL-unquoted
- Forwarded 'by' and 'for' are omitted if their value is unknown
- Tests modified accordingly
- Cleanup and improved documentation

* Add ASGI test.

* Linter

* Linter #2
2019-09-02 08:50:56 -05:00
Harsha Narayana
83864f890a
fix: #1631: add common contribution guidelines and towncrier detail to contribution guides
Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
2019-07-13 21:48:34 +05:30
Harsha Narayana
32eb8abb63
fix: #1631: add towncrier support and fix documentation warnings
Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
2019-07-13 21:47:48 +05:30
Lagicrus
b7df86e7dd Updated routing docs (#1620)
* Updated routing docs

Updated routing docs to show all supported types as defined within 3685b4de85/sanic/router.py (L18)
Added example code for all examples besides regex
Added examples of queries that work with that type and ones that would not

* Tweak to call out string not str

Related to https://github.com/huge-success/sanic/pull/1620#discussion_r300120962

* Changed to using code comments to achieve a mono space like display

To address https://github.com/huge-success/sanic/pull/1620#discussion_r300120726

* Adjusted to list

Following https://github.com/huge-success/sanic/pull/1620#discussion_r300120726
2019-07-04 07:14:10 -05:00
BananaWanted
72b445621b Respect X-Forward-* headers and generate correct URLs in url_for (#1465)
* handle forwarded address in request

* added test cases

* Fix lint errors

* Fix uncovered code branch

* Update docstrings

* Update documents

* fix import order
2019-07-04 07:13:43 -05:00
Alex
d5e9aae425
Fix a minor typo in websocket.rst. 2019-06-30 22:11:02 -07:00
Yun Xu
e2d65ba57c fix readthedoc changelog page 2019-06-20 22:35:47 -07:00
7
891f99d71d
Merge pull request #1475 from tomchristie/asgi-refactor-attempt
ASGI refactoring attempt
2019-06-20 16:33:44 -07:00
Adam Hopkins
fb61834a2e Add ASGI documentation 2019-06-18 09:57:42 +03:00
7
8fbbe94fe1
Merge pull request #1436 from jotagesales/config_from_object_string
Config from object string
2019-06-16 16:58:43 -07:00
G.Ted
09acd64ba1 Fix typo in request_data.md, docs. 2019-06-11 11:09:29 +09:00
Harsha Narayana
13079c6e30 GIT-1591 Strict Slashes behavior fix (#1594)
* fix: GIT-1591: fix strict_slashes option inheriting behavior

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* doc: GIT-1591: add documentation exlaining the strict_slashes behavior

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* fix: GIT-1591: fix deprecated for test_client

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
2019-06-06 07:21:58 -05:00
Adam Hopkins
bb2bd2fe53 Point extensions page to awesome-sanic repo (#1596) 2019-05-28 08:13:12 -05:00
Harsha Narayana
29bf967a7e
doc: GIT-1582: add fedora package dependency
Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
2019-05-20 06:46:18 +05:30
7
12f1985375
Merge pull request #1576 from huge-success/conda-docs
Add conda install and download stats
2019-05-15 22:42:25 -07:00
Adam Hopkins
bb800c9db8 Add conda install and download stats 2019-05-15 09:54:02 +03:00
Adam Hopkins
193dbe89cd Remove Python 3.5 references in docs 2019-05-14 11:21:24 +03:00
7
ae2b8f0056
Merge pull request #1562 from huge-success/testing-client
Testing client
2019-05-03 06:32:26 +08:00
Adam Hopkins
ccd4c9615c Create requests-async based TestClient, remove aiohttp dependency, drop Python 3.5
Update all tests to be compatible with requests-async
Cleanup testing client changes with black and isort
Remove Python 3.5 and other meta doc cleanup
rename pyproject and fix pep517 error
Add black config to tox.ini
Cleanup tests and remove aiohttp
tox.ini change for easier development commands
Remove aiohttp from changelog and requirements
Cleanup imports and Makefile
2019-04-30 15:26:06 +03:00
andreymal
9615e37ef9
Add file streaming section to the streaming documentation page 2019-04-20 23:50:19 +03:00
andreymal
6be12ba773
Upadte documentation for streaming response 2019-04-20 23:38:16 +03:00
andreymal
5c9ba189bc Add options to control the behavior of Request.remote_addr (#1539)
* Add options to control the behavior of Request.remote_addr

* Update tests for Request.remote_addr

* Update documentation for Request.remote_addr
2019-04-16 08:30:28 -05:00
Jeremie Pardou-Piquemal
f4bc0efc31 Fix #1551 missing parameter in create_server 2019-04-15 22:18:35 +02:00
Daniel Golding
3bedb223fc Add 19.03 release to changelog (#1537) 2019-03-29 10:34:13 -05:00
cakemanny
dd32d81726 fix typos in docs 2019-03-28 01:05:39 +00:00
Amit Garu
c42731a55c await keyword missing fix in response doc (#1520) 2019-03-19 07:15:28 -05:00
Sam Havens
abf8534ea9 fix typo in Asyncio example (#1510)
* fix typo

* args to kwargs
2019-03-15 12:28:15 -05:00
Moshe Zada
773a66bc5b Fix typo (#1516) 2019-03-15 11:49:18 -05:00
Serge Fedoruk
2a15583b87 add Request.not_grouped_args, deprecation warning Request.raw_args (#1476)
* add Request.not_grouped_args, deprecation warning Request.raw_args

* add 1 more test for coverage

* custom parser for Request.args and Request.query_args, some additional tests

* add docs for custom queryset parsing

* fix import sorting

* docstrings for get_query_args and get_args methods

* lost import
2019-03-14 09:04:05 -05:00
Jotagê Sales
bee7cfa6aa Merge branch 'master' of github.com:huge-success/sanic into config_from_object_string 2019-03-05 01:10:09 -03:00
Daniel Thorn
d5813152ab Allow sanic test client to bind to a random port (#1376) 2019-03-04 15:23:03 -06:00
Jotagê Sales
eacf78b83c Merge branch 'master' of github.com:huge-success/sanic into config_from_object_string 2019-03-04 00:37:59 -03:00
Harsha Narayana
348964fe12 Enable Middleware Support for Blueprint Groups (#1399)
* enable blueprint group middleware support

This commit will enable the users to implement a middleware at the
blueprint group level whereby enforcing the middleware automatically to
each of the available Blueprints that are part of the group.

This will eanble a simple way in which a certain set of common features
and criteria can be enforced on a Blueprint group. i.e. authentication
and authorization

This commit will address the feature request raised as part of Issue #1386

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* enable indexing of BlueprintGroup object

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* rename blueprint group file to fix spelling error

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* add documentation and additional unit tests

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* cleanup and optimize headers in unit test file

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* fix Bluprint Group iteratable method

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* add additional unit test to check StopIteration condition

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* cleanup iter protocol implemenation for blueprint group and add slots

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* fix blueprint group middleware invocation identification

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>

* feat: enable list behavior on blueprint group object and use append instead of properly to add blueprint to group

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
2019-03-03 16:26:05 -06:00
Tom Christie
123f00eee6
Added "databases"
Adds https://github.com/encode/databases to the "Database Integration" section.
2019-02-14 13:44:18 +00:00
Mykhailo Kushchenko
42bf103269 Remove deleted repo (#1487)
https://github.com/Sniedes722/Sanic-OAuth  (Sanic-OAuth: OAuth Library for connecting to & creating your own token providers.) returns  404
2019-02-08 08:43:43 -06:00
0xflotus
c8d2a462e3 did you mean specific? (#1486) 2019-02-06 16:28:32 -06:00
Kevin ZHANG Qing
4f70dba935 sanic-zipkin (#1483) 2019-02-05 07:59:33 -06:00
Jacob
52bdd1d5a2 Add stream support for bp.add_route() (#1482)
* Fix #1454

* Update doc

* Fix F632 in response.py
2019-02-05 07:47:46 -06:00
Denis Makogon
b89c533818 Adding doc 2019-01-15 15:04:30 +02:00
Eli Uriegas
2af229eb1a
Merge pull request #1445 from huge-success/r0fls-977
add handler name to request as endpoint
2019-01-08 16:12:25 -08:00