Ethernet demo : any /POST request sample please ?

General discussion on mikroBasic PRO for PIC.
Author
Message
phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Ethernet demo : any /POST request sample please ?

#1 Post by phil31 » 22 Jan 2014 23:11

hi all,

i play with the Ethernet lib and would like to serve POST request.
all work as expected with GET request. i can serve my pages :o)

but i can't find a reliable solution to retrieve the body part of the POST request ...?
please any suggestions ? sample ?
any compiler, internal or external ..

thanks, regards
Phil

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Ethernet demo : any /POST request sample please ?

#2 Post by marina.petrovic » 23 Jan 2014 16:14

Hi,

Our Ethernet library is wrote to TCP/IP level, and POST request is implementation application level,
so because of that we didn't provided any example related with POST requests.

Please, take a look at this explanation:
http://www.w3schools.com/tags/ref_httpmethods.asp

Best regards,
Marina

phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#3 Post by phil31 » 23 Jan 2014 16:28

Hi Marina,

thanks for your link, but I'm sorry I don't understand your answer !
the HTTP is an application protocol .. GET or POST are on same level !

so from your side view, with your library, I can't reply to POST request ?

thanks for your explanations, regards
Phil
Last edited by phil31 on 24 Jan 2014 00:42, edited 1 time in total.

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: Ethernet demo : any /POST request sample please ?

#4 Post by aCkO » 23 Jan 2014 16:39


phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#5 Post by phil31 » 23 Jan 2014 19:02

oh thanks guy, I missed this link during my search !
I will check it now

regards

phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#6 Post by phil31 » 27 Jan 2014 23:59

in fact there is no /POST request sample in that thread, they only explain how POST request are send !


Marina, please can you explain a little more what is the problem with our libray please ?
and ==> "so from your side view, with your library, I can't reply to POST request ?"

thanks,
Phil

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Ethernet demo : any /POST request sample please ?

#7 Post by marina.petrovic » 28 Jan 2014 14:52

Hi,

Sorry for misunderstanding, maybe I didn't expressed well in my previous post.

When I said that our Ethernet library is wrote to TCP/IP level, I thought that only simple examples are tested and provided
with the library and if you need POST request example, you will need to write it by yourself (application level).

I hoped that explanation that I send you can help and also the forum topic that aCkO posted.

Best regards,
Marina

phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#8 Post by phil31 » 28 Jan 2014 15:13

Well, I understand more your answer ! I already know that you provide only GET example.

anyway, the link provide by aCkO, don't help me : I already know how work a POST request and there is no example to show me how retrieve all lines from the request.

the easy way with GET sample, is that "all" important information, are immediately next after the /GET word ..and until the HTTP1.1\r\n\

Even if you don't provide POST sample, can you provide us enough information about how are managed the RX buffer and how the data are provided in this buffer to the users ?

when I try to catch "/POST" in that buffer (same as if we wait /GET), then I found it ! right..
but all data after that seem to be fragmented .. with a lot of irrelevant data between /POST and eventually "content-length" just before the beginning of the POST body..
I say eventually, because "content-length" is not ever find !!

thanks for you explanation
regards

Sy
Posts: 708
Joined: 10 Dec 2009 13:41
Location: UK

Re: Ethernet demo : any /POST request sample please ?

#9 Post by Sy » 29 Jan 2014 15:30

POST data follows after the HTTP headers, the end of the headers is indicated by \r\n\r\n (A blank line)

The posted data then follows, each data item is prefixed with the name of the field the data corresponds to followed by an '=' character, the data may then be URL encoded.

Multiple data items are delimited by the '&' character.
Kind Regards,
Sy

BarryP
Posts: 517
Joined: 02 Apr 2007 03:57
Location: New Zealand

Re: Ethernet demo : any /POST request sample please ?

#10 Post by BarryP » 29 Jan 2014 21:54

Hi,
Recon you need to power up Wireshark & capture the transactions.
when doing simple GET , the actual request will most likely fit inside one packet.
You don't get to see the SYN/FIN housekeeping.
A POST however , will most likely be broken into multiple packets that need to be managed .

perhaps you need to look at using the STACK version of the ethernet Lib.
Either way , Wireshark will enlighten you ! .

phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#11 Post by phil31 » 30 Jan 2014 00:42

hi BarryP

yes you surely point to the right answer ..
the POST request is broken in multiple packet :(

what do you mean by
"perhaps you need to look at using the STACK version of the ethernet Lib."
what/where is the STACK version ?

thanks for your advice
regards

BarryP
Posts: 517
Joined: 02 Apr 2007 03:57
Location: New Zealand

Re: Ethernet demo : any /POST request sample please ?

#12 Post by BarryP » 30 Jan 2014 06:42

Hi,
I don't have any real world experience using it , but it's in the Libstock .
http://www.libstock.com/projects/view/1 ... et-library

Sy
Posts: 708
Joined: 10 Dec 2009 13:41
Location: UK

Re: Ethernet demo : any /POST request sample please ?

#13 Post by Sy » 30 Jan 2014 09:55

Maybe I've misunderstood, but I thought what was being asked for was a way to interpret the HTTP data on the server once it had been posted ?

If this is the case then the data will not be chunked, it will be in one contiguous data stream that can be interpreted by the code.

If you what you are asking for is how to interpret the response then the response 'may' be chunked, but this is the same for delivery of any large data including pages.

But since you have asked specifically about the PIC code, I think what you are asking for is the server side, in which case forget about multi-part packets (chunks), and focus on the data stream.
Kind Regards,
Sy

phil31
Posts: 348
Joined: 02 Apr 2009 15:02
Location: France
Contact:

Re: Ethernet demo : any /POST request sample please ?

#14 Post by phil31 » 30 Jan 2014 10:23

hi BarryP and Sy

well you make me confuse now .. my problem Is right on the server side, with the ME Ethernet library.

my problem is more like suggest BarryP : the data I retrieve, when I do a POST request (on the client, a button do a POST request instead a GET), I can catch the first packet with the line "/POST .... \r\n" ..
but in the same packet, I don't find the next of the request : the header end, then the body part of the request.

I need to wait a lot of call to "Net_Ethernet_Intern_UserTCP" before find only some part of the header/body request and the parts are mixed .. !
as we don't know (or I forget some function?), we don't know the size of the RX buffer message. it's is hard to define a start and a end inside the RX buffer and keep only the request message.

I open a ticket to ME team, to know how work the RX buffer. but for now, no reply ..

BarryP ==> you mean to manage the "socket^.state", to know when I can keep data from RX buffer or not ?
then reconstruct the full request ?

thanks guys, have a nice day

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Ethernet demo : any /POST request sample please ?

#15 Post by marina.petrovic » 30 Jan 2014 16:22

Hi,

I believe that I answered you on this question via support desk so we continue our correspondence there.

Best regards,
Marina

Post Reply

Return to “mikroBasic PRO for PIC General”