On Thu, Feb 21, 2013 at 12:58 PM, Christian Mueller
<[email protected]> wrote:
> Hi Paolo
>
> First, for WMS requests, solution 2) is recommended. Lets have a look a the
> output you included in your last mail trying solution 1).
>
> 302 is not an error code, it is an HTTP redirect. The redirect url is stored
> in the "location" response header attribute.  In your php sample, the login
> request is NOT successful and you are redirected to the geoserver login
> page. (I am not used to develop in PHP and I cannot give you a hint).
>
> The curl example works well. Login is successful and you are redirected to
> the Geoserver start page.
>
> As you can see you always get a 302 response code. I would switch to basic
> auth.
>
> Christian

You are definitely right, and I have got to the same conclusion.
curl request is working well, I have seen that i get 302 (page
redirect) also when browsing to that page.
What was wrong was my Python code: I had to set  HTTP Content-Type header to
"application/x-www-form-urlencoded" , as suggested here [1] and now it
is working well.

For future reference, this is the working code:

from httplib2 import Http
from urllib import urlencode
url = 'http://myserver/geoserver/j_spring_security_check'
hds = {
    "content-type": "application/x-www-form-urlencoded",
}
http = Http()
data = dict(username="myuser", password="mypassword")
gs_resp, gs_content = http.request(url, method="POST",
body=urlencode(data), headers=hds )

thanks a lot again!
p

[1]  
http://stackoverflow.com/questions/5385699/python-httplib2-http-not-sending-post-parameters

-- 
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to