Skip to content

HTTP to HTTPS redirect forgets original method [urllib.request] #124815

@Jean-Luc-Picard-2021

Description

@Jean-Luc-Picard-2021

Bug report

Bug description:

>>> request = urllib.request.Request('https://wildorchard.com/collections/teaware', method='HEAD')
>>> response = urllib.request.urlopen(request)
>>> response.read()
b''
>>> request = urllib.request.Request('http://wildorchard.com/collections/teaware', method='HEAD')
>>> response = urllib.request.urlopen(request)
>>> response.read()
b'<!doctype html>\n<html class="no-js" lang="en">\n<head>\n\n\n  

In the first request everything works finde, the HEAD method doesn't return a response
body, subsequently response.read() gives a byte sequent of length zero.

In the second request, the final URL is the same, but something goes wrong, mostlikely
during redirect the method gets lost, since now the response body is not empty.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions