librelist archives

« back to archive

Trailing slash inconsistency/madness between flask app on MacOS X and Linux

Trailing slash inconsistency/madness between flask app on MacOS X and Linux

From:
Giovanni Di Milia
Date:
2013-02-19 @ 16:13
Hi all,

I'm writing some test cases for a flask application.

This application has a blueprint like this:

@api_blueprint.route('/api/search/', methods=['GET'])
def search():
    return 'foobar'

My test is trying to verify that a request like:

http://127.0.0.1:5000/api/search
returns a status code 301

This test is working fine on a CentOS 6 server (and on any other linux
machine I tried)

In fact a very simple get request gives the right result:

In [1]: import requests
In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
Starting new HTTP connection (1): 127.0.0.1
In [3]: r.history
Out[3]: (<Response [301]>,)
In [4]: r.status_code
Out[4]: 200

but it is failing on my Mac Pro with Mac OS X 10.6.8 and python 2.6
installed through MacPorts.

on the Mac the same simple request gives directly a status code 200:

In [1]: import requests
In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
Starting new HTTP connection (1): 127.0.0.1
In [3]: r.history
Out[3]: []
In [4]: r.status_code
Out[4]: 200

Obviously I already checked that I have the same version of Flask on both
machines.

Anybody knows why there is this annoying difference in behavior?

Thanks!

Re: [flask] Trailing slash inconsistency/madness between flask app on MacOS X and Linux

From:
Edd Robinson
Date:
2013-02-22 @ 07:53
It’s possible that the web server is rewriting your urls on one machine 
and not the other due to differences in package versions.

At least, that's a possibility (I would be surprise by such a drastic 
change across versions)...

Have you checked the versions of your other packages on each system?


Cheers,
Edd

On 19 Feb 2013, at 16:13, Giovanni Di Milia <gdimilia@cfa.harvard.edu> wrote:

> Hi all,
> 
> I'm writing some test cases for a flask application.
> 
> This application has a blueprint like this:
> 
> @api_blueprint.route('/api/search/', methods=['GET'])
> def search():
>     return 'foobar'
> 
> My test is trying to verify that a request like:
> 
> http://127.0.0.1:5000/api/search
> returns a status code 301
> 
> This test is working fine on a CentOS 6 server (and on any other linux 
machine I tried)
> 
> In fact a very simple get request gives the right result:
> 
> In [1]: import requests
> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> Starting new HTTP connection (1): 127.0.0.1
> In [3]: r.history
> Out[3]: (<Response [301]>,)
> In [4]: r.status_code
> Out[4]: 200
> 
> but it is failing on my Mac Pro with Mac OS X 10.6.8 and python 2.6 
installed through MacPorts.
> 
> on the Mac the same simple request gives directly a status code 200:
> 
> In [1]: import requests
> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> Starting new HTTP connection (1): 127.0.0.1
> In [3]: r.history
> Out[3]: []
> In [4]: r.status_code
> Out[4]: 200
> 
> Obviously I already checked that I have the same version of Flask on 
both machines.
> 
> Anybody knows why there is this annoying difference in behavior?
> 
> Thanks!

Re: [flask] Trailing slash inconsistency/madness between flask app on MacOS X and Linux

From:
Giovanni Di Milia
Date:
2013-02-22 @ 15:53
Hi Edd,
thanks for your answer.

I've not checked anything else because I'm use the development webserver
integrated in Flask (sorry, I forgot to mention this).

I'm assuming that there is no interaction between the development webserver
and apache settings... Am I wrong?

Is there a way to check/customize the configuration of the development
webserver?

Thanks,
Giovanni

On Fri, Feb 22, 2013 at 2:53 AM, Edd Robinson <me@eddrobinson.net> wrote:

> It’s possible that the web server is rewriting your urls on one machine
> and not the other due to differences in package versions.
>
> At least, that's a possibility (I would be surprise by such a drastic
> change across versions)...
>
> Have you checked the versions of your other packages on each system?
>
>
> Cheers,
> Edd
>
>
> On 19 Feb 2013, at 16:13, Giovanni Di Milia <gdimilia@cfa.harvard.edu>
> wrote:
>
> Hi all,
>
> I'm writing some test cases for a flask application.
>
> This application has a blueprint like this:
>
> @api_blueprint.route('/api/search/', methods=['GET'])
> def search():
>     return 'foobar'
>
> My test is trying to verify that a request like:
>
> http://127.0.0.1:5000/api/search
> returns a status code 301
>
> This test is working fine on a CentOS 6 server (and on any other linux
> machine I tried)
>
> In fact a very simple get request gives the right result:
>
> In [1]: import requests
> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> Starting new HTTP connection (1): 127.0.0.1
> In [3]: r.history
> Out[3]: (<Response [301]>,)
> In [4]: r.status_code
> Out[4]: 200
>
> but it is failing on my Mac Pro with Mac OS X 10.6.8 and python 2.6
> installed through MacPorts.
>
> on the Mac the same simple request gives directly a status code 200:
>
> In [1]: import requests
> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> Starting new HTTP connection (1): 127.0.0.1
> In [3]: r.history
> Out[3]: []
> In [4]: r.status_code
> Out[4]: 200
>
> Obviously I already checked that I have the same version of Flask on both
> machines.
>
> Anybody knows why there is this annoying difference in behavior?
>
> Thanks!
>
>

Re: [flask] Trailing slash inconsistency/madness between flask app on MacOS X and Linux

From:
Markus Unterwaditzer
Date:
2013-02-22 @ 20:52
Giovanni Di Milia <gdimilia@cfa.harvard.edu> wrote:

>Hi Edd,
>thanks for your answer.
>
>I've not checked anything else because I'm use the development
>webserver
>integrated in Flask (sorry, I forgot to mention this).
>
>I'm assuming that there is no interaction between the development
>webserver
>and apache settings... Am I wrong?
>
>Is there a way to check/customize the configuration of the development
>webserver?
>
>Thanks,
>Giovanni
>
>On Fri, Feb 22, 2013 at 2:53 AM, Edd Robinson <me@eddrobinson.net>
>wrote:
>
>> It’s possible that the web server is rewriting your urls on one
>machine
>> and not the other due to differences in package versions.
>>
>> At least, that's a possibility (I would be surprise by such a drastic
>> change across versions)...
>>
>> Have you checked the versions of your other packages on each system?
>>
>>
>> Cheers,
>> Edd
>>
>>
>> On 19 Feb 2013, at 16:13, Giovanni Di Milia
><gdimilia@cfa.harvard.edu>
>> wrote:
>>
>> Hi all,
>>
>> I'm writing some test cases for a flask application.
>>
>> This application has a blueprint like this:
>>
>> @api_blueprint.route('/api/search/', methods=['GET'])
>> def search():
>>     return 'foobar'
>>
>> My test is trying to verify that a request like:
>>
>> http://127.0.0.1:5000/api/search
>> returns a status code 301
>>
>> This test is working fine on a CentOS 6 server (and on any other
>linux
>> machine I tried)
>>
>> In fact a very simple get request gives the right result:
>>
>> In [1]: import requests
>> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
>> Starting new HTTP connection (1): 127.0.0.1
>> In [3]: r.history
>> Out[3]: (<Response [301]>,)
>> In [4]: r.status_code
>> Out[4]: 200
>>
>> but it is failing on my Mac Pro with Mac OS X 10.6.8 and python 2.6
>> installed through MacPorts.
>>
>> on the Mac the same simple request gives directly a status code 200:
>>
>> In [1]: import requests
>> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
>> Starting new HTTP connection (1): 127.0.0.1
>> In [3]: r.history
>> Out[3]: []
>> In [4]: r.status_code
>> Out[4]: 200
>>
>> Obviously I already checked that I have the same version of Flask on
>both
>> machines.
>>
>> Anybody knows why there is this annoying difference in behavior?
>>
>> Thanks!
>>
>>

Can you verify that behavior with other http clients than requests? cURL? 
wget? urllib2? Some browsers?

-- Markus

Re: [flask] Trailing slash inconsistency/madness between flask app on MacOS X and Linux

From:
Teo Klestrup Röijezon
Date:
2013-02-23 @ 01:30
You said you checked the Flask version, but did you check the Werkzeug
version (as, IIRC, both routing and the web server are pretty much wrappers
around Werkzeug functionality)?


On 22 February 2013 21:52, Markus Unterwaditzer <markus@unterwaditzer.net>wrote:

> Giovanni Di Milia <gdimilia@cfa.harvard.edu> wrote:
>
> >Hi Edd,
> >thanks for your answer.
> >
> >I've not checked anything else because I'm use the development
> >webserver
> >integrated in Flask (sorry, I forgot to mention this).
> >
> >I'm assuming that there is no interaction between the development
> >webserver
> >and apache settings... Am I wrong?
> >
> >Is there a way to check/customize the configuration of the development
> >webserver?
> >
> >Thanks,
> >Giovanni
> >
> >On Fri, Feb 22, 2013 at 2:53 AM, Edd Robinson <me@eddrobinson.net>
> >wrote:
> >
> >> It’s possible that the web server is rewriting your urls on one
> >machine
> >> and not the other due to differences in package versions.
> >>
> >> At least, that's a possibility (I would be surprise by such a drastic
> >> change across versions)...
> >>
> >> Have you checked the versions of your other packages on each system?
> >>
> >>
> >> Cheers,
> >> Edd
> >>
> >>
> >> On 19 Feb 2013, at 16:13, Giovanni Di Milia
> ><gdimilia@cfa.harvard.edu>
> >> wrote:
> >>
> >> Hi all,
> >>
> >> I'm writing some test cases for a flask application.
> >>
> >> This application has a blueprint like this:
> >>
> >> @api_blueprint.route('/api/search/', methods=['GET'])
> >> def search():
> >>     return 'foobar'
> >>
> >> My test is trying to verify that a request like:
> >>
> >> http://127.0.0.1:5000/api/search
> >> returns a status code 301
> >>
> >> This test is working fine on a CentOS 6 server (and on any other
> >linux
> >> machine I tried)
> >>
> >> In fact a very simple get request gives the right result:
> >>
> >> In [1]: import requests
> >> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> >> Starting new HTTP connection (1): 127.0.0.1
> >> In [3]: r.history
> >> Out[3]: (<Response [301]>,)
> >> In [4]: r.status_code
> >> Out[4]: 200
> >>
> >> but it is failing on my Mac Pro with Mac OS X 10.6.8 and python 2.6
> >> installed through MacPorts.
> >>
> >> on the Mac the same simple request gives directly a status code 200:
> >>
> >> In [1]: import requests
> >> In [2]: r = requests.get('http://127.0.0.1:5000/api/search')
> >> Starting new HTTP connection (1): 127.0.0.1
> >> In [3]: r.history
> >> Out[3]: []
> >> In [4]: r.status_code
> >> Out[4]: 200
> >>
> >> Obviously I already checked that I have the same version of Flask on
> >both
> >> machines.
> >>
> >> Anybody knows why there is this annoying difference in behavior?
> >>
> >> Thanks!
> >>
> >>
>
> Can you verify that behavior with other http clients than requests? cURL?
> wget? urllib2? Some browsers?
>
> -- Markus
>