From: Christian M. <chr...@os...> - 2013-02-21 14:42:15
|
Fine, but be aware of the fact that each new cookie creates an HTTP session on the Geoserver side wasting resources you do not need for WMS requests. At the end of the day, it is your decision :-) Christian 2013/2/21 Paolo Corti <pc...@gm...> > On Thu, Feb 21, 2013 at 12:58 PM, Christian Mueller > <chr...@os...> 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 > |