pWebRespInfo->nCode as -1292 | developer.brewmp.com pWebRespInfo->nCode as -1292 | developer.brewmp.com

Developer

pWebRespInfo->nCode as -1292

Forums:

Hello,
I am doing a Post request...but whne hcecking the response code i am getting it as -1292...checked it in AEEError.h...it says "mal formed header"...though i am not able to understand where is the problem...posting the code below.

http_webrequest()
{
char* url="http://xxxx:8080/webapplication/device/";
int8 data[3]={1,2,3};
char* header ="X-Method:POST\r\nContent-Type:application/binary\r\nContent-Length:3";

ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_WEB,(void**)&pMe->m_pIWeb);
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_SOURCEUTIL,(void**)&pMe->m_pISourceUtil);
int length=ISOURCEUTIL_SourceFromMemory(pMe->m_pISourceUtil,data,3,NULL,NULL,&pMe->m_pISource);
CALLBACK_Init(&pMe->m_Callback,WebReadCB,pMe);
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,url,WEBOPT_METHOD,"POST",WEBOPT_HEADER,header,WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH,3,WEBOPT_STATUSHANDLER,WebAction_Status,WEBOPT_END));

WebAction_Status(void *p, WebStatus ws, void *pVal)
{

WebReadCB(void* cxt)
{
MIDlet* pMe=(MIDlet*)cxt;
WebRespInfo* pWebRespInfo = IWEBRESP_GetInfo(pMe->m_pIWebResp);

int rescode=pWebRespInfo->nCode; // rescode is -1292

Where can be the possible problem.

I want to set three elements in Header as :-

X-Method:POST\r\n
Content-Type:application/binary\r\n
Content-Length:3

which is properly set...though it say's "mal formed header".

help appreciated
amal

The problem is likely because some of the arguments passed to IWEB_GetResponse are on the stack. From the BREW API documentation:
Quote: *AN IMPORTANT NOTE ABOUT WEBOPT LIFETIMES*
The pointers that represent pVals in the above list of WebOpts (like extra header strings) must stay valid until the response callback fires. They are not copied unless WEBOPT_COPYOPTS is included in the list of options ** So the header information is probably being overwritten before IWeb gets to it. You can look at the rest of the documentation for information on how to get it to work correctly.

The problem is likely because some of the arguments passed to IWEB_GetResponse are on the stack. From the BREW API documentation:
Quote: *AN IMPORTANT NOTE ABOUT WEBOPT LIFETIMES*
The pointers that represent pVals in the above list of WebOpts (like extra header strings) must stay valid until the response callback fires. They are not copied unless WEBOPT_COPYOPTS is included in the list of options ** So the header information is probably being overwritten before IWeb gets to it. You can look at the rest of the documentation for information on how to get it to work correctly.

Thanks Greg for that valuable reply...made all data pointers global..and things started to work out...
Though, am noticing an unusual thing...
After a success hit to the server...the next time i hit i get the same code as -1292...though no change on either client side or server side...and also checked to see my server is working alright.
It happens almost alternately...once it works , the second time it gives the same code as -1292.
What could be the possible reason?
help appreciated
amal

Thanks Greg for that valuable reply...made all data pointers global..and things started to work out...
Though, am noticing an unusual thing...
After a success hit to the server...the next time i hit i get the same code as -1292...though no change on either client side or server side...and also checked to see my server is working alright.
It happens almost alternately...once it works , the second time it gives the same code as -1292.
What could be the possible reason?
help appreciated
amal

Greg wrote:The problem is likely because some of the arguments passed to IWEB_GetResponse are on the stack. From the BREW API documentation:
So the header information is probably being overwritten before IWeb gets to it. You can look at the rest of the documentation for information on how to get it to work correctly.
Thanks Greg for your reply.

Greg wrote:The problem is likely because some of the arguments passed to IWEB_GetResponse are on the stack. From the BREW API documentation:
So the header information is probably being overwritten before IWeb gets to it. You can look at the rest of the documentation for information on how to get it to work correctly.
Thanks Greg for your reply.

Hi,
Quote:Originally Posted by amalshah71
After a success hit to the server...the next time i hit i get the same code as -1292...though no change on either client side or server side...and also checked to see my server is working alright.
It happens almost alternately...once it works , the second time it gives the same code as -1292.
also encountering the same problem when I am trying to upload an image , have you got the solution. please share...

Hi,
Quote:Originally Posted by amalshah71
After a success hit to the server...the next time i hit i get the same code as -1292...though no change on either client side or server side...and also checked to see my server is working alright.
It happens almost alternately...once it works , the second time it gives the same code as -1292.
also encountering the same problem when I am trying to upload an image , have you got the solution. please share...