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

Native Development

Reply
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none
Accepted Solution

BB10: How to Get the Response Header

[ Edited ]

Hi guys,

 

I would like to how to get the Response Header of a request made by using a tipical QNetworkAccessManager. What I really need is to get the server's date and I know the response header has it.

 

I saw you can access some header in the reply object of the requestFinished() function. But none of them is the Respone Header. 

 

Does anyone have any idea about it?

 

Thanks in advance.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: BB10: How to Get the Response Header

[ Edited ]

Hi,

 

If you're subscribing to QNetworkManager's void finished ( QNetworkReply * reply ) signal, use:

 

reply->rawHeaderList() to get a list of all available headers.

reply->header( param ) to get known headers, but they don't include Date.

reply->rawHeader("Date") to get the date or other custom headers.

 

http://qt-project.org/doc/qt-4.8/qnetworkreply.html#rawHeader

Returns the raw contents of the header headerName as sent by the remote server. If there is no such header, returns an empty byte array, which may be indistinguishable from an empty header. Use hasRawHeader() to verify if the server sent such header field.


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none

Re: BB10: How to Get the Response Header

Thanks a lot Zmey!
Please use plain text.