Sign in

username or email:

password:



Not a member?
Forgot your Password?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Discussion Groups

See Also

DSPFPGA

Discussion Groups | Rabbit-Semi | parse user data not from a HTML FORM

This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions, flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.


So far in May, you have voted 0 times ou of a total of 20 votes by the community.
Please help us clean the archives from unuseful discussion threads by using the voting system! Details here.


Is this thread worth a thumbs up?

+3

parse user data not from a HTML FORM - Ty - May 23 11:53:50 2012

Sample POST.c and POST2.c explain how to parse user data from a HTML FORM. However, I am require to parse any POST with user data send via an app instead of HTML FORM. I am given the variable names of the user data but this user data is either json encode or xml encode. I am trying to get the developer of the app to send these user data url-encode.

My question is, how do I parse these user data? And how do I return a http POST RESPONSE?





(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: parse user data not from a HTML FORM - markreds81 - May 24 15:32:58 2012



In Dynamic C SDK there is no native libraries for parsing xml or json data formats. In my opinion I think these formats may be very complex and expensive (in terms of memory e cpu cycles) for a Rabbit core module, especially if you have lots of data to manage.

Anyway, from Dynamic C 9.62 there is available the HTTP client lib which let you to communicate with a external web server (if your rcm module acts as a client) via standard HTTP commands GET and POST.
With GET you must send your parameters in the URL encoded format but you have some limits in this case and each parameter needs to be converted in a text representation and url-encoded.
With POST you can fill the body of the HTTP request with every kind of raw, binary data format (integers, floats, strings, arrays, etc). You must explicit declare the "application/octect-stream" mime type in the headers.

I used this way in my application context, where my rcm module is a client that makes requests to my tomcat server. With java EE and servlets I can parse the data posted by the rabbit and send a response to it in the same way.

If you haven't the HTTP client, you can obtain the same result using a standard TCP socket (remeber: HTTP is a simple protocol over a TCP socket, so with a few lines of code, you can obtain your http client implementation).

If your rcm module acts as a server instead, you can write a SSPEC_RESOURCE_P_CGI callback function that parse the POSTed binary data in the request's body and return an "application/octect-stream" response to the client.

In this context I assume that client and server know what kind of data they exchange in their HTTP sessions.

I hope this can help you.

Regards.

--- In r..., "Ty" wrote:
>
> Sample POST.c and POST2.c explain how to parse user data from a HTML FORM. However, I am require to parse any POST with user data send via an app instead of HTML FORM. I am given the variable names of the user data but this user data is either json encode or xml encode. I am trying to get the developer of the app to send these user data url-encode.
>
> My question is, how do I parse these user data? And how do I return a http POST RESPONSE?
>





(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: parse user data not from a HTML FORM - Ty - May 24 21:11:26 2012

Thanks for the valuable information. My rabbit has a rabbit-server running on it but I also need a HTTP web service server to accept POST REQUEST. In terms of parsing xml or json encoded user data isn't really a problem. There are libraries such as http://zserge.bitbucket.org/jsmn.html which can easily be ported to dynamic c. My problem is how do I get this user data and where is this userdata? Is there a buffer containing the body of post/user-data?

--- In r..., "markreds81" wrote:
>
> In Dynamic C SDK there is no native libraries for parsing xml or json data formats. In my opinion I think these formats may be very complex and expensive (in terms of memory e cpu cycles) for a Rabbit core module, especially if you have lots of data to manage.
>
> Anyway, from Dynamic C 9.62 there is available the HTTP client lib which let you to communicate with a external web server (if your rcm module acts as a client) via standard HTTP commands GET and POST.
> With GET you must send your parameters in the URL encoded format but you have some limits in this case and each parameter needs to be converted in a text representation and url-encoded.
> With POST you can fill the body of the HTTP request with every kind of raw, binary data format (integers, floats, strings, arrays, etc). You must explicit declare the "application/octect-stream" mime type in the headers.
>
> I used this way in my application context, where my rcm module is a client that makes requests to my tomcat server. With java EE and servlets I can parse the data posted by the rabbit and send a response to it in the same way.
>
> If you haven't the HTTP client, you can obtain the same result using a standard TCP socket (remeber: HTTP is a simple protocol over a TCP socket, so with a few lines of code, you can obtain your http client implementation).
>
> If your rcm module acts as a server instead, you can write a SSPEC_RESOURCE_P_CGI callback function that parse the POSTed binary data in the request's body and return an "application/octect-stream" response to the client.
>
> In this context I assume that client and server know what kind of data they exchange in their HTTP sessions.
>
> I hope this can help you.
>
> Regards.
>
> --- In r..., "Ty" wrote:
> >
> > Sample POST.c and POST2.c explain how to parse user data from a HTML FORM. However, I am require to parse any POST with user data send via an app instead of HTML FORM. I am given the variable names of the user data but this user data is either json encode or xml encode. I am trying to get the developer of the app to send these user data url-encode.
> >
> > My question is, how do I parse these user data? And how do I return a http POST RESPONSE?
>




(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: parse user data not from a HTML FORM - markreds81 - May 25 3:21:56 2012



Yes, in the HttpState structure allocated by the rabbit web server when a client start a session with a GET or POST command. You need to use the http_* function apis of the http.lib. Take a look at chapter 4 of TCP/IP User's Manual vol. 2. I think this can be very useful.

--- In r..., "Ty" wrote:
>
> Thanks for the valuable information. My rabbit has a rabbit-server running on it but I also need a HTTP web service server to accept POST REQUEST. In terms of parsing xml or json encoded user data isn't really a problem. There are libraries such as http://zserge.bitbucket.org/jsmn.html which can easily be ported to dynamic c. My problem is how do I get this user data and where is this userdata? Is there a buffer containing the body of post/user-data?
>
> --- In r..., "markreds81" wrote:
> >
> >
> >
> > In Dynamic C SDK there is no native libraries for parsing xml or json data formats. In my opinion I think these formats may be very complex and expensive (in terms of memory e cpu cycles) for a Rabbit core module, especially if you have lots of data to manage.
> >
> > Anyway, from Dynamic C 9.62 there is available the HTTP client lib which let you to communicate with a external web server (if your rcm module acts as a client) via standard HTTP commands GET and POST.
> > With GET you must send your parameters in the URL encoded format but you have some limits in this case and each parameter needs to be converted in a text representation and url-encoded.
> > With POST you can fill the body of the HTTP request with every kind of raw, binary data format (integers, floats, strings, arrays, etc). You must explicit declare the "application/octect-stream" mime type in the headers.
> >
> > I used this way in my application context, where my rcm module is a client that makes requests to my tomcat server. With java EE and servlets I can parse the data posted by the rabbit and send a response to it in the same way.
> >
> > If you haven't the HTTP client, you can obtain the same result using a standard TCP socket (remeber: HTTP is a simple protocol over a TCP socket, so with a few lines of code, you can obtain your http client implementation).
> >
> > If your rcm module acts as a server instead, you can write a SSPEC_RESOURCE_P_CGI callback function that parse the POSTed binary data in the request's body and return an "application/octect-stream" response to the client.
> >
> > In this context I assume that client and server know what kind of data they exchange in their HTTP sessions.
> >
> > I hope this can help you.
> >
> > Regards.
> >
> > --- In r..., "Ty" wrote:
> > >
> > > Sample POST.c and POST2.c explain how to parse user data from a HTML FORM. However, I am require to parse any POST with user data send via an app instead of HTML FORM. I am given the variable names of the user data but this user data is either json encode or xml encode. I am trying to get the developer of the app to send these user data url-encode.
> > >
> > > My question is, how do I parse these user data? And how do I return a http POST RESPONSE?
> > >
>





(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )