Problem with IWeb "POST" | developer.brewmp.com Problem with IWeb "POST" | developer.brewmp.com

Developer

Problem with IWeb "POST"

Forums:

Hi,
I have func:

void Web_StartPost(CWebData *WebData, char Url[], char *Header, uint8 *Data, uint32 Size)
{
Web_CleanUp(WebData);

STRCPY(WebData->Url, Url);
STRCPY(WebData->Header, Header);

ISourceUtil *SU;
if (ISHELL_CreateInstance(WebData->a->m_pIShell, AEECLSID_SOURCEUTIL,(void**)&SU) == SUCCESS) {
ISOURCEUTIL_SourceFromMemory( SU, Data, Size, NULL, NULL, &WebData->Source);
ISOURCEUTIL_Release(SU);
}
//uint8 Temp[1000];
//ISOURCE_Read(WebData->Source, (char *)Temp, 10); // With this I check if all Data is copied into WebData->Source (ISource)

IWEB_GetResponse(WebData->Web, (WebData->Web, &WebData->WebResp, &WebData->WebCB, WebData->Url,
WEBOPT_HANDLERDATA, WebData,
WEBOPT_HEADER, WebData->Header, // In my case it is "X-Method: POST\r\nContent-Type: application/octet-stream\r\n"
WEBOPT_METHOD, "POST",
WEBOPT_BODY, WebData->Source,
//WEBOPT_CONTENTLENGTH, Size, // If I uncoment this, I always geting -1293 nCode error (wrong CONTENTLENGTH value), but why, I dont know. Size = 133.
WEBOPT_HEADERHANDLER, Web_HeaderHandler,
//WEBOPT_STATUSHANDLER, Web_StatusNotification,
WEBOPT_END));

Server don't geting my WEBOPT_BODY data. Why?

Also I want to know if the WEBOPT_CONTENTLENGTH is an obligatory parametr for POSTing data to web. Please help me to understand what wrong in my case.

Also I want to know if the WEBOPT_CONTENTLENGTH is an obligatory parametr for POSTing data to web. Please help me to understand what wrong in my case.

This is the method for navigating url using post method
if ((IPeek *)0 != pipPostData) // post information
{
IWEB_GetResponse(pIWeb,
(pIWeb, &piWResp, &cb, sActiveURL,
WEBOPT_HANDLERDATA, this,
WEBOPT_HEADER, "X-Method: POST\r\nContent-Type: application/x-www-form-urlencoded\r\n",
WEBOPT_HEADERHANDLER, Header,
WEBOPT_METHOD, "POST",
WEBOPT_BODY, pipPostData,
WEBOPT_CONTENTLENGTH, STRLEN(sPostData),
WEBOPT_USERAGENT, sHeader,
WEBOPT_END));
}
markdude

This is the method for navigating url using post method
if ((IPeek *)0 != pipPostData) // post information
{
IWEB_GetResponse(pIWeb,
(pIWeb, &piWResp, &cb, sActiveURL,
WEBOPT_HANDLERDATA, this,
WEBOPT_HEADER, "X-Method: POST\r\nContent-Type: application/x-www-form-urlencoded\r\n",
WEBOPT_HEADERHANDLER, Header,
WEBOPT_METHOD, "POST",
WEBOPT_BODY, pipPostData,
WEBOPT_CONTENTLENGTH, STRLEN(sPostData),
WEBOPT_USERAGENT, sHeader,
WEBOPT_END));
}
markdude

Thanks for reply, Markdude.
I changed my code to this
void Web_StartPost(CWebData *WebData, char Url[], char *Header, uint8 *Data, uint32 Size)
{
Web_CleanUp(WebData);
WebData->Stoped = FALSE;
STRCPY(WebData->Url, Url);
STRCPY(WebData->Header, Header);
ISourceUtil *SU;
if (ISHELL_CreateInstance(WebData->a->m_pIShell, AEECLSID_SOURCEUTIL,(void**)&SU) == SUCCESS) {
ISOURCEUTIL_PeekFromMemory(SU, (void *)Data, Size, NULL, NULL, &WebData->Peek);
ISOURCEUTIL_Release(SU);
}
/* // Check for data receive into IPeek
uint8 Temp[1000];
IPEEK_Read(WebData->Peek, (char *)Temp, 1000);
*/
IWEB_GetResponse(WebData->Web, (WebData->Web, &WebData->WebResp, &WebData->WebCB, WebData->Url,
WEBOPT_HANDLERDATA, WebData,
WEBOPT_HEADER, "X-Method: POST\r\nContent-Type: application/x-www-form-urlencoded\r\n",
WEBOPT_HEADERHANDLER, Web_HeaderHandler,
WEBOPT_METHOD, "POST",
WEBOPT_BODY, WebData->Peek,
WEBOPT_CONTENTLENGTH, Size,
WEBOPT_END));

, but in this case it always geting nCode error -1293, that means wrong WEBOPT_CONTENTLENGTH. I can't understand why... =(

Thanks for reply, Markdude.
I changed my code to this
void Web_StartPost(CWebData *WebData, char Url[], char *Header, uint8 *Data, uint32 Size)
{
Web_CleanUp(WebData);
WebData->Stoped = FALSE;
STRCPY(WebData->Url, Url);
STRCPY(WebData->Header, Header);
ISourceUtil *SU;
if (ISHELL_CreateInstance(WebData->a->m_pIShell, AEECLSID_SOURCEUTIL,(void**)&SU) == SUCCESS) {
ISOURCEUTIL_PeekFromMemory(SU, (void *)Data, Size, NULL, NULL, &WebData->Peek);
ISOURCEUTIL_Release(SU);
}
/* // Check for data receive into IPeek
uint8 Temp[1000];
IPEEK_Read(WebData->Peek, (char *)Temp, 1000);
*/
IWEB_GetResponse(WebData->Web, (WebData->Web, &WebData->WebResp, &WebData->WebCB, WebData->Url,
WEBOPT_HANDLERDATA, WebData,
WEBOPT_HEADER, "X-Method: POST\r\nContent-Type: application/x-www-form-urlencoded\r\n",
WEBOPT_HEADERHANDLER, Web_HeaderHandler,
WEBOPT_METHOD, "POST",
WEBOPT_BODY, WebData->Peek,
WEBOPT_CONTENTLENGTH, Size,
WEBOPT_END));

, but in this case it always geting nCode error -1293, that means wrong WEBOPT_CONTENTLENGTH. I can't understand why... =(

Why nobody didn't help me yet? =(((

Why nobody didn't help me yet? =(((

I suspect, you shouldn't read the data for test, cause it will move read marker of WebData->Peek to the end of data, so, IWeb won't read it...
/* // Check for data receive into IPeek
uint8 Temp[1000];
IPEEK_Read(WebData->Peek, (char *)Temp, 1000);
*/

I suspect, you shouldn't read the data for test, cause it will move read marker of WebData->Peek to the end of data, so, IWeb won't read it...
/* // Check for data receive into IPeek
uint8 Temp[1000];
IPEEK_Read(WebData->Peek, (char *)Temp, 1000);
*/