Hi I have compiled HTTP symbian example app for S60 3rd edition.
I have no problems with get requests (I can send them and they reach server) but when I am trying to send POST reguest I am getting
Error - 7334 (that means empty body)
but actually I am filing the body
I invoke function from symbian HTTP example in this manner:
<code> iClient->IssueHTTPPostL(someAdrressThatIsOK,_L8("text/plain"),_L8("someparameter1=lala"));
</code>
Am I doing sth wrong here ? Does anyone has a working example of HTTP post ??
The IssueHTTPPostL function from the symbian examples looks like this:
<code>
void CWebClientEngine::IssueHTTPPostL(const TDesC8& aUri,
const TDesC8& aContentType,
const TDesC8& aBody)
{
// Parse string to URI
TUriParser8 uri;
uri.Parse(aUri);
// Copy data to be posted into member variable; iPostData is used later in
// methods inherited from MHTTPDataSupplier.
delete iPostData;
iPostData = aBody.AllocL();
// Get request method string for HTTP POST
RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
RHTTPSession::GetTable());
// Open transaction with previous method and parsed uri. This class will
// receive transaction events in MHFRunL and MHFRunError.
iTransaction = iSession.OpenTransactionL(uri, *this, method);
// Set headers for request; user agent, accepted content type and body's
// content type.
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL(hdr, HTTP::EContentType, aContentType);
// Set this class as an data supplier. Inherited MHTTPDataSupplier methods
// are called when framework needs to send body data.
/*
MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);
*/
// Submit the transaction. After this the framework will give transaction
// events via MHFRunL and MHFRunError.
iTransaction.SubmitL();
iRunning = ETrue;
_LIT(KConnecting,"Connecting post...");
iObserver.ClientEvent(KConnecting);
}
</code>

Reply With Quote

