libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] POST file content without the form method


From: alexander . hetzl
Subject: Re: [libmicrohttpd] POST file content without the form method
Date: Wed, 28 Jun 2017 16:40:16 +0200 (CEST)

Hi Evgeny,

your hint was exactly what I needed to come back on the road. I studied the 
examples from the src/testcurl folder and rewrote the HTTP request handler 
logic in my project. Now it is working :-)

Thanks and best wishes,
Alex

---- libmicrohttpd development and user mailinglist wrote ----
>
> 26.06.2017, 16:35, "address@hidden" <address@hidden>:
> > 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:address@hidden: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:address@hidden: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

[Prev in Thread] Current Thread [Next in Thread]