[En-Nut-Discussion] Webserver via POST

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue May 3 15:43:17 CEST 2011


Hi Werner,

> In my simplified example to read out the POST message, the content of
> the value is really strange. So when I read out the value variable which
> should contain the value of the parameter it contians more than the word
> from the form. It looks like an header oder something. It looks like:
> "wert" beispieltext ----------------102378947192
> Content-Disposition:form-data; name=...... and so on. 

Ok, your data is not just url encoded form data (like is is send of you
have "normal" form entries) but you get the multipart encoded file you
want to upload.

Nut/OS does not support all the various encoding format etc. which might
be possible when using a POST request, so NutHttpProcessPostQuery can
only be used to parse standard form data which is send URL encoded.

> What it the proper sense of "NutHttpProcessPostQuery()? And why I have
> to use after that functions including "Get" (for example:
> NutHttpGetParameterCount)? Is this function only convert the data that I
> can read out them with this functions or where I am wrong?

NutHttpProcessPostQuery is parsing post data so that you can use the
same functions as when having a GET request. But this works only on URL
encoded data (normal form entries)

NutHttpGetParameterCount just returns the number of name=value pairs.

> Furthermore it's not really clear to me how I can copy files via POST
> into the MMC. Writing MMC is no problem but I think caching the file on
> the board is impossible. So I have to copy bit by bit on my Card. But
> how?

If you found the start of your file, just write it chunk by chunk on the
card using write() for example.

What you have to do:

Find the beginning of the multipart section (which is "beispieltext
----------------102378947192"), next read the file header and use this
information if needed. Find the beginning of the file and read it until
you got the end of the file (same boundary text again)

See http://www.vivtek.com/rfc1867.html which explains how the file
upload works.

Regards,

Ole Reinhardt

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 




More information about the En-Nut-Discussion mailing list