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

Web and WebWorks Development

Reply
Contributor
_MARIO_
Posts: 16
Registered: ‎04-26-2011
My Device: Bold 9780
My Carrier: Vodafone Spain

[WebWorks] Modify User-Agent string on requests.

[ Edited ]

Hi :-),

 

I'm trying to perform an xmlhttprequest sending some custom headers. I've done two different tests, one modifying UserAgent header and a second one adding myself a specific header.

 

The server side part of the application basically echoes back whatever it receives. The application compiles and executes correctly and in fact I can retrieve the rest of the header values but It seems I cannot modify UserAgent or add a specific header. Is this true or am I doing something wrong?

 

My code more or less looks like:

 

        var reqUrl = "https://xxxx";
        var httpReq = new XMLHttpRequest();
        httpReq.onreadystatechange = handleStateChange;
        httpReq.open('GET', reqUrl, false);
        
        httpReq.setRequestHeader('User-Agent','CustomAgent');
        httpReq.setRequestHeader('MyHeader','HeaderValue');
        httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        httpReq.setRequestHeader('Connection', 'close');
        httpReq.send();

 

        if (httpReq.readyState == 4) {
            query1.innerHTML = httpReq.responseText;
        }

 

Regards

Please use plain text.
XP1
New Member
XP1
Posts: 1
Registered: ‎08-09-2011
My Device: N/A

Re: [WebWorks] Modify User-Agent string on requests.

Overriding the user agent is not allowed. This is not a bug.

http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method

Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: [WebWorks] Modify User-Agent string on requests.

Ditto

 

You sound like you've trying a XMPP hack

 

No help here




Click the like button if you find my posts useful!
Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: [WebWorks] Modify User-Agent string on requests.

So is there no way to change the user agent in WebWorks?

I'm trying to add a channel requested by a customer to my Tablet TV app but it blocks the Playbook because it's a "mobile browser" - if changing the user agent isn't possible, is there any other way around this?

-----------------------------------------------------------------------------------------



Please use plain text.