You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Views » Adding a http header to a request and redirecting

Hello,

I want, from server A (where my django application sits), to request server B with a certain Http header.

I tried doing this in my view:
response=HttpResponseRedirect('http://xxxxxxxxxxxxxxxxxxxx')
response["myheader"] = header_value
return response

Unfortunately, when I check the headers with the firefox extension livehttpheaders, I see that server B doesnt get my header:

POST /ssologin/ HTTP/1.1
Host: localhost:8778
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8778/ssologin/
Content-Type: application/x-www-form-urlencoded
Content-Length: 35
username=Administrator&password=sds
HTTP/1.x 302 FOUND
Date: Thu, 20 Aug 2009 14:12:01 GMT
Server: WSGIServer/0.1 Python/2.3.7
MYHEADER: Administrator <--- my added header
Content-Type: text/html; charset=utf-8
Location: http://SERVER_B:7777/index/
----------------------------------------------------------
http://SERVER_B:7777/index/ <-- server B

GET /analytics/saw.dll?dashboard HTTP/1.1
Host: http://SERVER_B:7777
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8778/ssologin/
Cookie: nQuireID=thro3n86c29v612sbdav8ubt2egs30kqkk8r9mqzOr07UFe9W00
If-Modified-Since: Thu, 20 Aug 2009 14:06:59 GMT

HTTP/1.x 200 OK
Date: Thu, 20 Aug 2009 14:11:57 GMT
Server: Oracle-Application-Server-10g/10.1.3.4.0 Oracle-HTTP-Server
Content-Length: 1685
Cache-Control: private
Last-Modified: Thu, 20 Aug 2009 14:11:57 GMT
Expires: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=us-ascii

Apparently the header is in the django response, but when the redirection occurs, it is not "passed" to the server B.

Any idea how I can do that? thanks
sometimes.. i'm really confused..
why do you assume that a browser has to pass all response headers as request headers to the next server if you return a redirect?
I want from my django app on server A to redirect the user on server B. But server B only lets user in if there is a special header with a special value in the httprequest.

I'm not a django guru so I tried that way.
Obviously I was wrong.
Do you know a correct way?

thanks
this, again, has nothing to do with django - not even remotely.. and i have no idea why you think it does..
as you have seen for yourself django returns the header to the browser.. and the browser ignores it (just as specified in the HTTP: "Unrecognized header fields SHOULD be ignored by the recipient" http://tools.ietf.org/html/rfc2616#section-7.1 ) if your application requires additional header fields, the only way to do it is place a proxy between the server and the user.

why can't you simply pass your information as GET parameter?
I cannot put it in GET parameters because the server B can only be configured to look for a value either in the HTTP Header OR a cookie. (it's the Oracle Business Inteligence application, configured for Single sign on)

So even though it is not django related you seem to have a lot of knowledge so maybe you can offer a suggestion.
I have to redirect a user from my django application to this OBIEE server with either a special value in a cookie on in a header, what do you is the best (easiest) way to do it?

Thanks a lot.
unfortunately i have no idea about Oracle Business Intelligence - is it possible for you to create a script on the same host as it? if so you could make a simple script which sets a cookie for the current host.

if this is not possible, create a subdomain. within a subdomain you should be able to set a cookie for your main domain. (e.g. tools.oraclebusinessintelligence.mycompany.com can set a cookie for *.mycompany.com)





Powered by Sphene Community Tools