Re: [libmicrohttpd] Warnings from libmicrohttpd.h
Eh, yes. Should be fixed in 98cd69d1..867c58ad, please report if not. Happy hacking! Christian On 01/03/2018 12:10 PM, Tim Rühsen wrote: > Hi, > > I see these annoying from the user-included file libmicrohttpd.h (latest > git master). Could you fix it, please ? > > /usr/oms/src/wget2/x86_64-w64-mingw32/include/microhttpd.h:215:5: > warning: "__clang_major__" is not defined, evaluates to 0 [-Wundef] > #if __clang_major__+0 >= 5 || \ > ^~~ > /usr/oms/src/wget2/x86_64-w64-mingw32/include/microhttpd.h:216:42: > warning: "__clang_major__" is not defined, evaluates to 0 [-Wundef] >(!defined(__apple_build_version__) && (__clang_major__+0 > 3 || > (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \ > ^~~ > /usr/oms/src/wget2/x86_64-w64-mingw32/include/microhttpd.h:216:69: > warning: "__clang_major__" is not defined, evaluates to 0 [-Wundef] >(!defined(__apple_build_version__) && (__clang_major__+0 > 3 || > (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \ > > > With Best Regards, Tim > > signature.asc Description: OpenPGP digital signature
[libmicrohttpd] How to send a binary payload (octet-stream)?
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 #include #include 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
Re: [libmicrohttpd] How to send a binary payload (octet-stream)?
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 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 > #include > #include > > 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