Oh, I found a good explanation just after sensing my question: * @param[in,out] upload_data_size set initially to the size of the * @a upload_data provided; the method must update this * value to the number of bytes NOT processed;
... it seems I need to load the upload_data on demand. 🤔 I'm going to test it and back with some feedback ... On Fri, Jan 5, 2018 at 12:50 AM, silvioprog <silviop...@gmail.com> wrote: > Hi dudes! > > Consider the following file: > > http://brook.no-ip.org/download/content.bin > > request: > > # debugdump.txt just for debuging > $ url --header "Content-Type:application/octet-stream" --trace-ascii > debugdump.txt --data-binary @content.bin http://localhost:9090 > > and example: > > #include <microhttpd.h> > #include <stdio.h> > #include <string.h> > > static int answer_to_connection(void *cls, struct MHD_Connection *connection, > const char *url, const char *method, > const char *version, const char *upload_data, > size_t *upload_data_size, > void **con_cls) { > if (!*con_cls) { > *con_cls = (void *) 1; > return MHD_YES; > } > *con_cls = NULL; > printf("*upload_data_size: %zd\n", *upload_data_size); > return MHD_NO; > } > > int main(void) { > struct MHD_Daemon *daemon; > daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, 9090, NULL, NULL, > &answer_to_connection, NULL, MHD_OPTION_END); > getchar(); > MHD_stop_daemon(daemon); > return 0; > } > > the result is: > > *upload_data_size: 1995 > > but the upload_data buffer contains only 746 characters. OK, my file is a > binary that contains some NULLs, so it should be sent > via multipart/form-data, however, I've tested it with other servers and the > binary content is sent properly as application/octet-stream. (eg. NodeJS > uses its req.buffer to get octet-streams) > > It seems MHD's payload (upload_data) ends with first NULL character. So, > is there any chance to get a binary content without using HTML forms? > > Thank you! > -- Silvio Clécio