Author Topic: http.c. Not parsing form posts correctly  (Read 50223 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: http.c. Not parsing form posts correctly
« Reply #15 on: April 13, 2009, 07:18:46 PM »
Hi Stan

This support was added in SP4 of the SAM7X project.

If you download this service pack and look in the header of HTTP.c you will find:
   07.09.2008 Add plain text post support to enable posting parameters to application {27}
You can then just copy the relevant changes (it may also be necessary to take a couple of new defines from tcpip.h), or else you can install SP4 and work with that (generally this is recommended since it has a lot of new stuff - including USB suppoort).

Regards

Mark

Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
Re: http.c. Not parsing form posts correctly
« Reply #16 on: July 15, 2009, 05:04:36 AM »
Hi Thomas

I have implemented a version which solves the user name / password case. I will send you a new HTTP.c file (plus tcpip.h due to two new HTTP states). See the define PLAIN_TEXT_POST for the new bits which is activated locally in http.c. The define SUPPORT_POST_TEXT is not in fact used since the content type is not checked (the header has a different sequence in this case...) but I think that this should always be used together with SUPPORT_HTTP_POST_TO_APPLICATION because it probably doesn't make much sense to save to a file.

...
...

My tests on the simulator were good. There is however a restriction. The complete post must be received in one TCP frame. This will always be the case as long as the actual post data is not larger than about 1.2k in size - hopefully adequate for what you are doing (?).

...
...


Hi Mark,

I want to load some text data that is processed by my application, with the output stored into a file. Is it still the case that the maximum length of the text is still 1.2K? With the print to debug statement

Code: [Select]
        fnWrite(DebugHandle, (unsigned char *)ptrData, (QUEUE_TRANSFER)http_session->FileLength); // send to debug output

I only see the last 700 or so characters.

If so, how to I deal with it as my text data could be 10s of KB in length? I noticed that you provided a similar example for dealing with S records. Presumably, the size of the S-Records is greater than 1.2K


Cheers,

peter.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: http.c. Not parsing form posts correctly
« Reply #17 on: July 15, 2009, 11:19:37 AM »
Hi Peter

This depends on how the post is being made. If you post a file to the application there have never been any restrictions (each received frame is passed to the application via the event POSTING_DATA_TO_APP. The html controlling this uses the following (example) form case:

<form action=*A.bin enctype="multipart/form-data" method="post">
<p><input type="file" name="datafile" size="30" £DN0></p>
<p><input type="submit" value="Upload new bitmap for the TFT" £DN0></p>
</form>


Note that the *A.bin means that the file to be posted is destined for the application and not the file system. After the upload has completed the file A.bin will be served as default but can be overridden by the application, which also uses this to identify which post is concerned (if multiple types in the project).

In the case of posting parameters (as discussed specifically in this thread) there was originally a restriction that all post data needed to fit into a single TCP frame. This restriction no longer applies when the latest HTTP.c is used since the posting technique has been reworked and allows also the parameters to be passed to the application over multiple frames. The application still needs to collect the complete content if it needs all data before being able to start processing - usually however there are multiple parameters and each one can be handled individually.

Since you are talking about data of several 10k I expect that the file post method is what you actually need and not the form parameter post (?)

Regards

Mark




Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
Re: http.c. Not parsing form posts correctly
« Reply #18 on: July 16, 2009, 05:55:51 AM »
Hi Mark,

Thanks for the reply. I'll let you know how I get om.

Cheers,

Peter.

Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
Re: http.c. Not parsing form posts correctly
« Reply #19 on: July 16, 2009, 08:28:34 AM »
Hi Mark,

The data I'm trying to transfer is ascii text. The web page has a 80x24 Text window that the test is entered into. I could also be dropped in there by cut and past from an editor etc.

I want to to be able to parse the file translate it and store it in the file system. I also want to be able to take the data from the file reverse translate it and display it in the text window as well.

I'm not sure that the file transfer is what I'm after.

Is the 80x24 text window treated as a large parameter?

As to the parsing of the data, it is done 1 character at a time.

Cheers,

Peter.
« Last Edit: July 16, 2009, 08:31:00 AM by phomann »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: http.c. Not parsing form posts correctly
« Reply #20 on: July 16, 2009, 11:19:13 AM »
Hi Peter

I am not sure whether this is passed as a parameter but I expect it is. If you click on the form any watch the URL you will see whether it passes it after the ? in which case it is.
Also, if you watch the transfer with Wireshark it will be clear which method is being used.
Since you are treating each character at a time you will not have any problems with the fact that the transfer may be in several TCP frames.

regards

Mark