python / python/cpython

DELETE redirect not supported [urllib.request]

Open
#124,857 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug description:

Compare node.js:

> response = await fetch('http://www.xlog.ch/echo/delete?foo1=bar1&foo2=bar2',
...  {method:'DELETE'}); response.url
'https://www.xlog.ch/echo/delete?foo1=bar1&foo2=bar2'

With CPython:

request = urllib.request.Request('http://www.xlog.ch/echo/delete?foo1=bar1&foo2=bar2', method='DELETE')
response = urllib.request.urlopen(request)
urllib.error.HTTPError: HTTP Error 302:

I believe node.js fetch() redirects, whereas CPython thinks
302 is an error, since the method is neither HEAD, GET or PUT.

But its probably not an error, all methods are allowed:

image
https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with urllib.request and trace how an HTTP 302 response is handled for methods other than HEAD, GET, and PUT. Compare that path with the documented redirect behavior and the provided DELETE example; done means the intended DELETE redirect behavior is covered by a regression test without breaking existing redirect handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.