26.06.2017, 16:35, "[email protected]" <[email protected]>:
> I've used the largepost.c example and implemented the upload. When I perform 
> a test using cUrl, everything works fine.
>
> curl -F "payload=<remove.xml" http://username:password@localhost:9090
>
> However requirements changed and I need to change the logic from using the 
> form post to posting the file content directly without having a "key". Doing 
> this in cUrl looks like:
>
> curl -d "@remove.xml" http://username:password@localhost:9090
>
> Assume the signature of my iteratePost looks like this:
>
> static int iteratePost(void *conInfoCls,
>                        enum MHD_ValueKind kind,
>                        const char *key,
>                        const char *filename,
>                        const char *content_type,
>                        const char *transfer_encoding,
>                        const char *data,
>                        uint64_t off,
>                        size_t size);
>
> When i post the file content directly, some part of the files content is in 
> the key and some in the data variables. It would be possible to handle this; 
> however, if have a "=" character in the first section of the file, it seems 
> that libmicrohttpd is removing it. So lets assume the file remove.xml has the 
> following line at the beginning:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> What is receive in the iteratePost is:
> <?xml version"1.0" encoding="ISO-8859-1"?>
>
> Hence, the content is invalid.
>
> Is there a way in the library to handle this case?

Hi Alex,

If I understand you correctly, you are trying to upload some arbitrary data to 
MHD. Correct?

POST is designed to handle uploading of filled forms with data in format 
'name=value'. It cannot handle some random data.
If you want to push content of any local file, you should use PUT.

src/testcurl/test_put.c test_put_chunked.c and test_large_put.c may give you 
some inspiration.


-- 
Best Wishes,
Evgeny Grin


Reply via email to