| Author |
Message |
< extend ~ ofxHttpServer |
|
arturo
|
Posted: Sun Jul 05, 2009 2:27 pm |
|
|
| Site AdminJoined: Wed Apr 11, 2007 1:02 amPosts: 906Location: barcelona |
hi all during the development of pierre's grand mutual smiles project: http://www.80plus1.org/projects/grand-mutual-smileswe needed to transfer images between oF apps. at first the idea was to use an external http server + the ofxHttpUtils or a script to send the images from one app to the other. in the end we've used a library called microhttpd that converts the oF app into an http server itself. here's an addon for that library that allows to serve plain files from the file system or create custom responses using and ofEvent that is called whenever a new request arrive. it can attend get and post requests and with post, it can also receive files that are saved to a folder configured during the setup of the server. in the example the server works in the port 8888 so to test it run the app and from a browser connect to: http://localhost:8888/index.htmlthere are 2 options: - see the screen of the app as a web page that autorefresh. you should have the app in the foreground for this to actually work, if not the draw function is not going to be called. - post an image file: a web form will be shown where you can enter a name and an image file that will be sent and shown in the oF app. the addon uses the microhttpd library, in the zip there's versions for linux, linux64 and windows, don't have a mac to compile it right now.
Attachments:
ofxHttpServer.zip [886.02 KiB]
Downloaded 62 times
|
|
Top
|
|
|
joshuajnoble
|
Posted: Sun Jul 05, 2009 6:45 pm |
|
|
Joined: Thu May 31, 2007 2:32 pmPosts: 215Location: PDX |
Here's micro_httpd compiled for OSX. Thanks for the addon!
Attachments:
osx_libmicrohttpda.zip [4.39 KiB]
Downloaded 37 times
|
|
Top
|
|
|
shotgunninja
|
Posted: Thu Jul 16, 2009 3:09 pm |
|
|
Joined: Fri Nov 07, 2008 2:34 amPosts: 95Location: Kenosha, WI |
Wow. Very nice, guys! Now to start making PHP/CGI work with it, and start pushing C++ into the formerly Java- and M$.NET-dominated territory of Web Applications!
|
|
Top
|
|
|
Gestalt
|
Posted: Fri Jul 17, 2009 8:46 am |
|
|
| Joined: Wed Jul 16, 2008 8:07 amPosts: 63Location: Duesseldorf |
Hello!
I'm sorry, but on OS X I get some linker errors, complaining that some _MHD_ functions, all referenced from the ofxHttpd addon, could not be found. I made a subfolder in libs/microhttpd/lib called osx. I added the microhttpd for osx posted from joshuajnoble into the lib-subfolder. Then I added the addon as usual to my project. Did I forget anything?
Thanks, Gestalt
|
|
Top
|
|
|
arturo
|
Posted: Fri Jul 17, 2009 8:54 am |
|
|
| Site AdminJoined: Wed Apr 11, 2007 1:02 amPosts: 906Location: barcelona |
you need to add the library to the linker settings of your project. don't remember exactly how you configure this in xcode though.
|
|
Top
|
|
|
Gestalt
|
Posted: Fri Jul 17, 2009 12:01 pm |
|
|
| Joined: Wed Jul 16, 2008 8:07 amPosts: 63Location: Duesseldorf |
I thought this gets done automatically when adding an addon to Xcode (e.g. when adding openCv addon, i don't have to add anything in my project/linker settings). Can anybody tell me, how to do that?
|
|
Top
|
|
|
arturo
|
Posted: Fri Jul 17, 2009 9:05 pm |
|
|
| Site AdminJoined: Wed Apr 11, 2007 1:02 amPosts: 906Location: barcelona |
yes, opencv is added in every addon example so you don't need to add it. i think it has to be in project > settings > linker > other options
and there add
../../../addons/ofxHttpServer/libs/microhttpd/osx/libmicrohttpd.a
but if any xcode user can confirm it
|
|
Top
|
|
|
millermichaelx
|
Posted: Tue Nov 10, 2009 10:49 pm |
|
|
| Joined: Thu Nov 05, 2009 8:26 pmPosts: 5 |
LARGE POST FIELD BUG I discovered a bug in the post field code. if you have a post field that is large (ie greater than 500 characters) the value in the response.fields will only contain the end of the value. Example: data=REALLYLONG ~<500>~ DATAVALUE value should start with: REALLYLONG.... instead it starts with DATAVALUE This is because large fields are broken up into smaller parts but the ofxHTTPServer code does not handle that. To fix the situation, replace the if block at line 108 with: Code: if(!filename){ char * aux_data = new char[off+size+1]; memset(aux_data,0,size+1); if(off > 0) memcpy(aux_data,con_info->fields[key].c_str(),off); memcpy(aux_data+off*sizeof(char),data,size); con_info->fields[key] = aux_data; }
|
|
Top
|
|
|
|