Opened 8 years ago

Closed 8 years ago

#4380 defect closed duplicate (duplicate)

Missing slash (/) in the beginning of a path

Reported by: alexis Owned by: alexis
Priority: normal Milestone:
Component: core Keywords: _parse path slash
Cc: Thijs Triemstra Branch:
Author:

Description

When getting a web page that redirects using the "location" header, some sites omit the '/' at the beginning of the location. Web browsers add this / automatically but client.py don't. Here is a small patch to handle these situations.

example urls:

Attachments (2)

client_path_slash_at_beginning.diff (371 bytes) - added by alexis 8 years ago.
client_301_relative_location.diff (893 bytes) - added by alexis 8 years ago.
a better patch

Download all attachments as: .zip

Change History (9)

Changed 8 years ago by alexis

comment:1 Changed 8 years ago by alexis

Type: enhancementdefect

comment:2 Changed 8 years ago by Glyph

Keywords: review added
Owner: Glyph deleted

comment:3 Changed 8 years ago by Jean-Paul Calderone

Keywords: review removed
Owner: set to alexis

Thanks. Can you add a unit test for this behavior? Also, it looks like the fix may be a bit more complicated than what's in this patch. If the request URL was http://foo.com/bar/baz and the redirect is to quux.html, won't browsers request http://foo.com/bar/quux, rather than http://foo.com/quux.html?

Changed 8 years ago by alexis

a better patch

comment:4 Changed 8 years ago by alexis

You are right. Here is a better patch that will handle situations like the one you described. I'll try to write unit tests.

comment:5 Changed 8 years ago by alexis

Oops, it looks like my ticket is a duplicate of #3384.

comment:6 Changed 8 years ago by alexis

Why is there no twisted/web/test/test_webclient.py ?

comment:7 in reply to:  5 Changed 8 years ago by Thijs Triemstra

Cc: Thijs Triemstra added
Resolution: duplicate
Status: newclosed

Replying to alexis:

Oops, it looks like my ticket is a duplicate of #3384.

Closing it in that case. Can you make a patch against the branch (that also contains other fixes) in #3384? Please reopen if I misunderstood..

Note: See TracTickets for help on using tickets.