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

Use Forwarded, X-Forwarded-Scheme and X-Forwarded-Host for better scheme and host resolution #1881

Merged
merged 26 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Changes

- Do not unquote `+` in match_info values #1816

- Use Forwarded, X-Forwarded-Scheme and X-Forwarded-Host for better scheme and
host resolution. #1134

- Fix sub-application middlewares resolution order #1853

- Fix applications comparison #1866
Expand All @@ -52,6 +55,10 @@ Changes

- Make test server more reliable #1896

- Use Forwarded, X-Forwarded-Scheme and X-Forwarded-Host for better scheme and
host resolution. #1134


2.0.7 (2017-04-12)
------------------

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Enrique Saez
Erich Healy
Eugene Chernyshov
Eugene Naydenov
Evert Lammerts
Frederik Gladhorn
Frederik Peter Aalund
Gabriel Tremblay
Expand Down
1 change: 1 addition & 0 deletions aiohttp/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from abc import ABC, abstractmethod
from collections.abc import Iterable, Sized


PY_35 = sys.version_info >= (3, 5)


Expand Down
1 change: 1 addition & 0 deletions aiohttp/backport_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import string # pragma: no cover
from http.cookies import CookieError, Morsel # pragma: no cover


__all__ = ["CookieError", "BaseCookie", "SimpleCookie"] # pragma: no cover

_nulljoin = ''.join # pragma: no cover
Expand Down
9 changes: 5 additions & 4 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
from . import connector as connector_mod
from . import client_exceptions, client_reqrep, hdrs, http, payload
from .client_exceptions import * # noqa
from .client_exceptions import (ClientError, ClientOSError,
ServerTimeoutError, WSServerHandshakeError)
from .client_exceptions import (ClientError, ClientOSError, ServerTimeoutError,
WSServerHandshakeError)
from .client_reqrep import * # noqa
from .client_reqrep import ClientRequest, ClientResponse
from .client_ws import ClientWebSocketResponse
from .connector import * # noqa
from .connector import TCPConnector
from .cookiejar import CookieJar
from .helpers import (PY_35, CeilTimeout, TimeoutHandle,
deprecated_noop, sentinel)
from .helpers import (PY_35, CeilTimeout, TimeoutHandle, deprecated_noop,
sentinel)
from .http import WS_KEY, WebSocketReader, WebSocketWriter
from .streams import FlowControlDataQueue


__all__ = (client_exceptions.__all__ + # noqa
client_reqrep.__all__ + # noqa
connector_mod.__all__ + # noqa
Expand Down
1 change: 1 addition & 0 deletions aiohttp/client_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from asyncio import TimeoutError


__all__ = (
'ClientError',

Expand Down
1 change: 1 addition & 0 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .log import client_logger
from .streams import FlowControlStreamReader


try:
import cchardet as chardet
except ImportError: # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/client_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from .client_exceptions import ClientError
from .helpers import PY_35, PY_352, Timeout, call_later, create_future
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE,
WebSocketError, WSMessage, WSMsgType)
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, WebSocketError,
WSMessage, WSMsgType)


class ClientWebSocketResponse:
Expand Down
1 change: 1 addition & 0 deletions aiohttp/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections.abc import Mapping
from http.cookies import Morsel
from math import ceil

from yarl import URL

from .abc import AbstractCookieJar
Expand Down
1 change: 1 addition & 0 deletions aiohttp/formdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from . import hdrs, multipart, payload
from .helpers import guess_filename


__all__ = ('FormData',)


Expand Down
4 changes: 4 additions & 0 deletions aiohttp/hdrs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""HTTP Headers constants."""
from multidict import istr


METH_ANY = '*'
METH_CONNECT = 'CONNECT'
METH_HEAD = 'HEAD'
Expand Down Expand Up @@ -50,6 +51,7 @@
ETAG = istr('ETAG')
EXPECT = istr('EXPECT')
EXPIRES = istr('EXPIRES')
FORWARDED = istr('FORWARDED')
FROM = istr('FROM')
HOST = istr('HOST')
IF_MATCH = istr('IF-MATCH')
Expand Down Expand Up @@ -89,3 +91,5 @@
WANT_DIGEST = istr('WANT-DIGEST')
WARNING = istr('WARNING')
WWW_AUTHENTICATE = istr('WWW-AUTHENTICATE')
X_FORWARDED_HOST = istr('X-FORWARDED-HOST')
X_FORWARDED_PROTO = istr('X-FORWARDED-PROTO')
1 change: 1 addition & 0 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from . import hdrs
from .abc import AbstractCookieJar


try:
from asyncio import ensure_future
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions aiohttp/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .http_writer import (HttpVersion, HttpVersion10, HttpVersion11,
PayloadWriter, StreamWriter)


__all__ = (
'HttpProcessingError', 'RESPONSES', 'SERVER_SOFTWARE',

Expand Down
1 change: 1 addition & 0 deletions aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .log import internal_logger
from .streams import EMPTY_PAYLOAD, FlowControlStreamReader


__all__ = (
'HttpParser', 'HttpRequestParser', 'HttpResponseParser',
'RawRequestMessage', 'RawResponseMessage')
Expand Down
1 change: 1 addition & 0 deletions aiohttp/http_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .http_exceptions import HttpBadRequest, HttpProcessingError
from .log import ws_logger


__all__ = ('WS_CLOSED_MESSAGE', 'WS_CLOSING_MESSAGE', 'WS_KEY',
'WebSocketReader', 'WebSocketWriter', 'do_handshake',
'WSMessage', 'WebSocketError', 'WSMsgType', 'WSCloseCode')
Expand Down
1 change: 1 addition & 0 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .abc import AbstractPayloadWriter
from .helpers import create_future, noop


__all__ = ('PayloadWriter', 'HttpVersion', 'HttpVersion10', 'HttpVersion11',
'StreamWriter')

Expand Down
1 change: 1 addition & 0 deletions aiohttp/log.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging


access_logger = logging.getLogger('aiohttp.access')
client_logger = logging.getLogger('aiohttp.client')
internal_logger = logging.getLogger('aiohttp.internal')
Expand Down
1 change: 1 addition & 0 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .payload import (BytesPayload, LookupError, Payload, StringPayload,
get_payload, payload_type)


__all__ = ('MultipartReader', 'MultipartWriter', 'BodyPartReader',
'BadContentDispositionHeader', 'BadContentDispositionParam',
'parse_content_disposition', 'content_disposition_filename')
Expand Down
1 change: 1 addition & 0 deletions aiohttp/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
parse_mimetype, sentinel)
from .streams import DEFAULT_LIMIT, DataQueue, EofStream, StreamReader


__all__ = ('PAYLOAD_REGISTRY', 'get_payload', 'payload_type', 'Payload',
'BytesPayload', 'StringPayload', 'StreamReaderPayload',
'IOBasePayload', 'BytesIOPayload', 'BufferedReaderPayload',
Expand Down
1 change: 1 addition & 0 deletions aiohttp/payload_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def file_sender(writer, file_name=None):

from .payload import Payload, payload_type


__all__ = ('streamer',)


Expand Down
5 changes: 3 additions & 2 deletions aiohttp/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from aiohttp.web import Application

from .test_utils import unused_port as _unused_port
from .test_utils import (RawTestServer, TestClient, TestServer,
loop_context, setup_test_loop, teardown_test_loop)
from .test_utils import (RawTestServer, TestClient, TestServer, loop_context,
setup_test_loop, teardown_test_loop)


try:
import uvloop
Expand Down
1 change: 1 addition & 0 deletions aiohttp/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .abc import AbstractResolver


__all__ = ('ThreadedResolver', 'AsyncResolver', 'DefaultResolver')

try:
Expand Down
1 change: 1 addition & 0 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from . import helpers
from .log import internal_logger


__all__ = (
'EMPTY_PAYLOAD', 'EofStream', 'StreamReader', 'DataQueue', 'ChunksQueue',
'FlowControlStreamReader',
Expand Down
5 changes: 5 additions & 0 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .web_urldispatcher import PrefixedSubAppResource
from .web_ws import * # noqa


__all__ = (web_protocol.__all__ +
web_fileresponse.__all__ +
web_request.__all__ +
Expand Down Expand Up @@ -58,6 +59,10 @@ def __init__(self, *,
if loop is not None:
warnings.warn("loop argument is deprecated", ResourceWarning)

if secure_proxy_ssl_header is not None:
warnings.warn(
"secure_proxy_ssl_header is deprecated", ResourceWarning)

self._debug = debug
self._router = router
self._secure_proxy_ssl_header = secure_proxy_ssl_header
Expand Down
1 change: 1 addition & 0 deletions aiohttp/web_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .web_response import Response


__all__ = (
'HTTPException',
'HTTPError',
Expand Down
1 change: 1 addition & 0 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
HTTPRequestRangeNotSatisfiable)
from .web_response import StreamResponse


__all__ = ('FileResponse',)


Expand Down
1 change: 1 addition & 0 deletions aiohttp/web_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aiohttp.web_exceptions import HTTPMovedPermanently
from aiohttp.web_urldispatcher import SystemRoute


__all__ = (
'normalize_path_middleware',
)
Expand Down
1 change: 1 addition & 0 deletions aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .web_request import BaseRequest
from .web_response import Response


__all__ = ('RequestHandler', 'RequestPayloadError')

ERROR = http.RawRequestMessage(
Expand Down
Loading