webpage posts in v3.x

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 527
Joined: Mon May 12, 2008 10:55 am

webpage posts in v3.x

Post by SeeCwriter » Mon Dec 06, 2021 8:52 am

Regarding handling http posts, my webpage sends post data of: "udp_cmd=0B1%3E0%3B00A%2Cn96.126.105.86%3B-8%3B0%3B1%0D%0A", as captured by wireshark. What shows up in case eVariable is: 0B1>0;00A,n96.126.105.86;-8;0;1. My code is looking for "udp_cmd" to determine the type of data, and it uses the '\r' to determine the end of the data string in case multiple commands are received. But both of these are stripped off. I can probably work around the missing CR, but not sure what to do about the missing command type parameter.

v3.3.5 and NANO.

User avatar
pbreed
Posts: 1019
Joined: Thu Apr 24, 2008 3:58 pm

Re: webpage posts in v3.x

Post by pbreed » Mon Dec 06, 2021 1:06 pm

How are you handleing the post?
If you are using the normal post handler
Given the example you will see a name ==udp_cmd"
and Value with the \r stripped off...

Say your posting to URL mypost.com.

Create a call back...

void myPostCallBack(int sock, PostEvents event, const char * pName, const char * pValue)
{
switch (event)
{
// Called at the beginning of the post before any data is sent
case eStartingPost:
break;

// Called once for each variable in the form
case eVariable:
if (strcmp(pName,"udp_cmd")==0)
{pValue holds your variable
}
break;

// Called back when the post is complete. You should send your response here.
case eEndOfPost:
RedirectResponse(sock, "complete.html"); //Or do whatever your going to do to respond.
break;
}

}

//Then in global scope register to use it..
HtmlPostVariableListCallback postForm1("MYPostRootURL", myPostCallBack);

SeeCwriter
Posts: 527
Joined: Mon May 12, 2008 10:55 am

Re: webpage posts in v3.x

Post by SeeCwriter » Mon Dec 06, 2021 2:16 pm

That was the piece of information I was missing. Thank you.

Post Reply