Skip to content

aiohttp 3.8.0 wrong value of Request.rel_url.raw_path #6227

@ech0-py

Description

@ech0-py

Describe the bug

Wrong value of Request.rel_url.raw_path when request was made with url in absolute form

To Reproduce

  1. Make a simple server app with logging hook
from aiohttp import web


async def log(request, response):
    print('rel_url:', request.rel_url)
    print('raw_path:', request.rel_url.raw_path)


async def hello(request):
    return web.Response(text="Hello, world")


app = web.Application()
app.add_routes([web.get('/test', hello)])
app.on_response_prepare.append(log)
web.run_app(app, host='127.0.0.1', port=3322)
  1. Make a request using relative form of url:
    echo -e "GET /test HTTP/1.1\r\n\r\n" | nc -N 127.0.0.1 3322
  2. Make a request using absolute form of url:
    echo -e "GET http://aaa.com/test HTTP/1.1\r\n\r\n" | nc -N 127.0.0.1 3322

Expected behavior

Server logs the "raw_path" as /test in both cases

Logs/tracebacks

aiohttp==3.8.0

rel_url: /test
raw_path: /test

rel_url: http://abc.com/test
raw_path: http://abc.com/test

aiohttp==3.7.4

rel_url: /test
raw_path: /test

rel_url: http://abc.com/test
raw_path: /test

Python Version

Python 3.8.7

aiohttp Version

aiohttp==3.8.0

multidict Version

multidict==5.2.0

yarl Version

yarl==1.7.2

OS

Ubuntu 18.04

Related component

Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions