HTTP client
| Thu, 2004-10-28 09:27 | |
|
Hello,
I am a beginner in Symbian C++ developing. I am programming a simple HTTP client using RHTTPSession and RHTTPTransaction classes. In this application it's needed to obtain data transfer rate and several times values. My problem is that I don't know how can I get the total number of bytes of request/response and measure time between request are sent and the response are completely received. Thanks. |
|






Forum posts: 723
First, you will need to study HTTP specification, RFC 2616. For the length of an incoming chunk, you'll need to obtain the value of Content-Length response header. You can do this, if you register your class as an observer for transaction events. Have a look at MHTTPTransactionCallback class for more details. You have to register yourself for various events, like THTTPEvent::EGotResponseHeaders or THTTPEvent::ESubmit. This way, you'll know when you're issuing a request and when the response has arrived.
Cheers,
tOtE
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 14
I know Content-Length header, but it only contains the bytes of response content, and I need bytes of whole the response (which includes status line, response headers and body) and request in order to obtain bytes/sec of transaction.
I have been watching HTTP example client source code and I also have a MHTTPTransactionCallback class, but it doesn't receive THTTPEvent::ESubmit after it is called Submit() method. Do you how can it be possible?
Thanks a lot.
Forum posts: 723
Now I understood what you want to do. Well, there may be a few alternatives:
- first, collect all the parts of the response header and add their sizes ==> the sum will be the size of received bytes (okay, over HTTP).
- I've just discovered a function: RConnection::DataReceivedNotificationRequest. It may also be useful for you. How to get the HTTP session's RConnection?
...
THTTPHdrVal connHandle;
session.ConnectionInfo().Property( session.StringPool().StringF( HTTP::EHttpSocketConnection ), connHandle );
// do some error handling if Property method returns EFalse or
// connHandle.Type() != KTIntVal
RConnection connection = REINTERPRET_CAST( RConnection&, connHandle.Int() );
Hope that the code above works, I haven't even tried to compile it!
As to MHFRunL is not called after a request has been submitted - I don't know why it's not get called, it should be!
Cheers,
tOtE
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 14
Thank you very much, tote.
Forum posts: 44
i want to retrieve Content-Length in THTTPEvent::EGotResponseHeaders. how can i retrieve it.
please help me.