Re: [Repoze-dev] repoze.vhm and ports other than 80

2009-08-09 Thread Chris McDonough
On 8/9/09 12:15 PM, Martin Aspeli wrote:
> Chris McDonough wrote:
>> On 8/9/09 8:16 AM, Martin Aspeli wrote:
>>> Hi,
>>>
>>> I've been debugging some weirdness with deliverance 0.3 in front of
>>> repoze.vhm and the vhm_xhosts middleware, which specifically happens
>>> when the VHM host has a port in it (e.g. localhost:8000).
>>>
>>> Basically, Deliverance uses webob.Request, and in particular its 'url'
>>> property to construct some URLs. After repoze.vhm does its thing, the
>>> URL loses the port part.
>>>
>>> It seems that before repoze.vhm kicks in, environ['HTTP_HOST'] is e.g.
>>> 'localhost:8000'. Afterwards, it's just 'localhost'.
>>>
>>> This is done here, in middleware.py:
>>>
>>>environ['SERVER_NAME'] = host
>>>environ['HTTP_HOST'] = host
>>>environ['SERVER_PORT'] = port
>>>environ['SCRIPT_NAME'] = path
>>>
>>> If I change this to the following, the url comes through correctly in
>>> webob.Request:
>>>
>>>environ['SERVER_NAME'] = host
>>>environ['HTTP_HOST'] = "%s:%s" % (host, port,)
>>>environ['SERVER_PORT'] = port
>>>environ['SCRIPT_NAME'] = path
>>>
>>> Would it be OK to change repoze.vhm to do this (and get a new release)?
>>> Or is there something more sinister going on?
>>>
>>> Martin
>>>
>>>
>>
>> I don't know quite how to read the spec here:
>>
>> http://www.freesoft.org/CIE/RFC/2068/184.htm
>>
>> In particular, I'm not sure if we should strip the port out of the hostname 
>> if
>> the default port for the scheme is used.  It doesn't say MUST around that
>> description, so I'd assume not.  On the other hand, Firefox doesn't tack the
>> port number on for either https or http requests, so it might be a good idea 
>> to
>> follow that lead.  But delta that, yeah.  For non-standard ports, the VHM 
>> should
>> put the port in the http_host envvar.
>
> I implemented this in r6220.
>
> I made it hide the port when the port is 80, otherwise include it, and
> added tests for that.
>
> Any chance we can get a new release?

Done in PyPI, the "latest" plone and zope2 indexes on dist.repoze.org.

- C


>
> And also, any chance you can put a zopelib 2.10.8  and/or 2.10.9 on
> dist.repoze.org? See http://dist.saugus.net/zopelib-2.10.8.0.tar.gz
>
> Cheers,
> Martin
>

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] repoze.vhm and ports other than 80

2009-08-09 Thread Martin Aspeli
Chris McDonough wrote:
> On 8/9/09 8:16 AM, Martin Aspeli wrote:
>> Hi,
>>
>> I've been debugging some weirdness with deliverance 0.3 in front of
>> repoze.vhm and the vhm_xhosts middleware, which specifically happens
>> when the VHM host has a port in it (e.g. localhost:8000).
>>
>> Basically, Deliverance uses webob.Request, and in particular its 'url'
>> property to construct some URLs. After repoze.vhm does its thing, the
>> URL loses the port part.
>>
>> It seems that before repoze.vhm kicks in, environ['HTTP_HOST'] is e.g.
>> 'localhost:8000'. Afterwards, it's just 'localhost'.
>>
>> This is done here, in middleware.py:
>>
>>   environ['SERVER_NAME'] = host
>>   environ['HTTP_HOST'] = host
>>   environ['SERVER_PORT'] = port
>>   environ['SCRIPT_NAME'] = path
>>
>> If I change this to the following, the url comes through correctly in
>> webob.Request:
>>
>>   environ['SERVER_NAME'] = host
>>   environ['HTTP_HOST'] = "%s:%s" % (host, port,)
>>   environ['SERVER_PORT'] = port
>>   environ['SCRIPT_NAME'] = path
>>
>> Would it be OK to change repoze.vhm to do this (and get a new release)?
>> Or is there something more sinister going on?
>>
>> Martin
>>
>>
> 
> I don't know quite how to read the spec here:
> 
> http://www.freesoft.org/CIE/RFC/2068/184.htm
> 
> In particular, I'm not sure if we should strip the port out of the hostname 
> if 
> the default port for the scheme is used.  It doesn't say MUST around that 
> description, so I'd assume not.  On the other hand, Firefox doesn't tack the 
> port number on for either https or http requests, so it might be a good idea 
> to 
> follow that lead.  But delta that, yeah.  For non-standard ports, the VHM 
> should 
> put the port in the http_host envvar.

I implemented this in r6220.

I made it hide the port when the port is 80, otherwise include it, and 
added tests for that.

Any chance we can get a new release?

And also, any chance you can put a zopelib 2.10.8  and/or 2.10.9 on 
dist.repoze.org? See http://dist.saugus.net/zopelib-2.10.8.0.tar.gz

Cheers,
Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] repoze.vhm and ports other than 80

2009-08-09 Thread Chris McDonough
On 8/9/09 8:16 AM, Martin Aspeli wrote:
> Hi,
>
> I've been debugging some weirdness with deliverance 0.3 in front of
> repoze.vhm and the vhm_xhosts middleware, which specifically happens
> when the VHM host has a port in it (e.g. localhost:8000).
>
> Basically, Deliverance uses webob.Request, and in particular its 'url'
> property to construct some URLs. After repoze.vhm does its thing, the
> URL loses the port part.
>
> It seems that before repoze.vhm kicks in, environ['HTTP_HOST'] is e.g.
> 'localhost:8000'. Afterwards, it's just 'localhost'.
>
> This is done here, in middleware.py:
>
>   environ['SERVER_NAME'] = host
>   environ['HTTP_HOST'] = host
>   environ['SERVER_PORT'] = port
>   environ['SCRIPT_NAME'] = path
>
> If I change this to the following, the url comes through correctly in
> webob.Request:
>
>   environ['SERVER_NAME'] = host
>   environ['HTTP_HOST'] = "%s:%s" % (host, port,)
>   environ['SERVER_PORT'] = port
>   environ['SCRIPT_NAME'] = path
>
> Would it be OK to change repoze.vhm to do this (and get a new release)?
> Or is there something more sinister going on?
>
> Martin
>
>

I don't know quite how to read the spec here:

http://www.freesoft.org/CIE/RFC/2068/184.htm

In particular, I'm not sure if we should strip the port out of the hostname if 
the default port for the scheme is used.  It doesn't say MUST around that 
description, so I'd assume not.  On the other hand, Firefox doesn't tack the 
port number on for either https or http requests, so it might be a good idea to 
follow that lead.  But delta that, yeah.  For non-standard ports, the VHM 
should 
put the port in the http_host envvar.

- C



___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev