Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

HttpConnection: problems with requestProperty 'Host', bug or something

Hi, I'm dealing along several days with a problem, bug...whatever you want.

 

The fact is that I'm trying to stablish an HttpConnection (POST) througt BES with a BlackBerry device (8900 & 9360) and I can't  sent properly the parameter 'Host' as a requestProperty because this request property seems to be interpreted by an intermediate server before reach the final server and then, well, to resume, wrong things happens, you can imagine...

 

Specifically, I'm trying to send 'Host' as 'httpConnection.setRequestProperty("Host", "localhost");'. It seems that an intermediate server (or my own BlackBerry) read it and do something with it and then I get in the BlackBerry an http error code 400 and the response 'Connection refused localhost:80'. If I don't send this parameter the request reach the final server I want (but it fails there, because of implementation needs I must sent the parameter).

Does it exist any way in which the request parameters are passed to the final server (as it must be) whitout being interpreted along the way? Do you have any idea of how to solve my problem?

 

By the way with direct TCP connection (deviceside=true) all works fine, so the 'problem' should be inside the RIM network. Regrettably, connections must go thought BES, so this is not an option.

 

Thanks in advance

 

 

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: HttpConnection: problems with requestProperty 'Host', bug or something

Hi @yokese,

 

Try adding the following to your request:

 

conn.setRequestProperty("x-rim-transcode-content", "none");

Hope that helps,

 

E.

 

Contributor
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

Re: HttpConnection: problems with requestProperty 'Host', bug or something

Many thanks, but that is one request property I've included before and don't solve it....

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: HttpConnection: problems with requestProperty 'Host', bug or something

[ Edited ]

Can you post your code?

 

Can you try and use the real hostname / IP as the host value?

 

E.

Highlighted
Contributor
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

Re: HttpConnection: problems with requestProperty 'Host', bug or something

Well, thank you for your help.

 

About the code I think it'is fine, it's all about an issue in the RIM network that one RIM proxy read the http request parameter 'Host' and then redirect the query there. We've coded a simple 'proxy' in java inside our network to which we make initially our http request (setting 'Host' to it). This proxy rewrites de 'Host' parameter to localhost value and then redirect the request to the final server.

 

Once more time RIM knows know how to make things difficult to developpers....