[Catalog-sig] setuptools upload to pypi

Phillip J. Eby pje at telecommunity.com
Mon Jul 23 23:31:39 CEST 2007


At 11:03 PM 7/23/2007 +0200, Martin v. Löwis wrote:
> > because I turned of proxying from www.python.org/pypi
> >> to cheeseshop.python.org/pypi, and replaced it with redirection
> >> (302, temporary redirect) instead (temporary just in case people
> >> find problems with that).
> >
> > If you were doing that for POST requests, that is probably the source of
> > the problem.  You could always restrict the proxying to occur only for
> > non-GET requests, since IIRC distutils.command.register and
> > distutils.command.upload use POSTs.  GET requests generally have a much
> > wider leeway for safe redirection than POST requests do.
>
>What is the problem with redirects for POST? In particular, why doesn't
>urllib2 support it?

It's my understanding that a redirection response to a POST means 
"GET the location I'm giving you", not "sorry, you should POST to 
this other place instead."  At least, that's how I understand web 
browsers to interpret it, and I believe urllib2 does as well.

So, the issue is not one of "not supporting" POSTs, it's a question 
of what the semantics of a redirected POST should be.  As far as I'm 
aware, it doesn't cause the POST to repeat, although that *might* 
depend on the specific status code and HTTP version.


> > Of course, one must also preserve the query string in a redirected GET,
> > and I don't think Apache's Redirect directive does that either.  You can
> > certainly do it with mod_rewrite, however.
>
>I see - I was using a plain Redirect.
>
> > I expect that the combination of preserving query strings on
> > redirection, and only redirecting GETs should make the transition safe.
>
>Can you share the magic to do that? I'd really like to start phasing
>out www.python.org/pypi, although I now see that it will take a few
>Python releases to get the cheeseshop home page replaced in distutils.
>
>In particular, if I also keep the mod_proxy setup for the reverse
>proxy, how will it interact with the redirect for the GET only?

Well, if you are using mod_rewrite to do both the redirection and the 
proxying, then it should suffice to have the GET rewrite with [R] and 
the remainder use [P].

Something like:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^pypi(.*)$ 
http://cheeseshop.python.org/pypi$1?%{QUERY_STRING} [R,L]
RewriteRule ^pypi(.*)$ 
http://cheeseshop.python.org/pypi$1?%{QUERY_STRING} [P,L]

But I'd test that with some dummy URLs instead of 'pypi', 
first.  Notice that this is not using any mod_proxy directives, just 
using mod_rewrite proxy support.  I've never used the mod_proxy 
directives, actually, but I have used mod_rewrite proxying.



More information about the Catalog-SIG mailing list