Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HEAD requests should be HEAD requests upon redirect #99730

Closed
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@haampie

Description

@haampie

Bug report

Currently the following isFalse

fromurllib.requestimportRequest,urlopenlen(urlopen(Request("http://google.com",method="HEAD")).read())==0# False

But this isTrue

len(urlopen(Request("http://www.google.com",method="HEAD")).read())==0# True

This is becausehttp://google.com redirects with 302 tohttp://www.google.com.

This means that checking for existence of some file by URL will actually download the file when the URL responds with a redirect. This makes no sense. Also the HTTP spec says nothing about changing HEAD requests into GET requests; it just says that everything but GET and HEAD requests should require user interaction on redirect, which Python violates, but there's a comment on that explaining it's an active choice to violate the spec there.

To me it seems like this is an oversight. Note thatcurl -LI http://google.com also sticks to HEAD requests.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp