Pages: [1] 2 3 4
Author Topic: ofxHttpServer  (Read 5328 times)
arturo
Administrator
barcelona

Posts: 2395

Gravatar


WWW
ofxHttpServer
« on: July 05, 2009, 03:27:14 PM »

hi all

during the development of pierre's grand mutual smiles project:

http://www.80plus1.org/projects/grand-mutual-smiles

we 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.html

there 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.

* ofxHttpServer.zip (886.02 KB - downloaded 288 times.)
Logged
joshua noble
Global Moderator
Cascadia

Posts: 1252

Gravatar

Let's make better mistakes tomorrow.


WWW
Re: ofxHttpServer
« Reply #1 on: July 05, 2009, 07:45:19 PM »

Here's micro_httpd compiled for OSX. Thanks for the addon!

* osx_libmicrohttpda.zip (4.39 KB - downloaded 186 times.)
Logged

shotgunninja
Kenosha, WI

Posts: 95

Gravatar


Re: ofxHttpServer
« Reply #2 on: July 16, 2009, 04:09:52 PM »

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!  :mrgreen:
Logged

http://www.lakeviewlegends.us/ - FIRST Robotics Team site

And no, I'm NOT the Shotgun Ninja from here: http://www.cactus-soft.co.nr/
(Although, it would be kind of cool...)
Gestalt
Duesseldorf

Posts: 76

Gravatar


Re: ofxHttpServer
« Reply #3 on: July 17, 2009, 09:46:15 AM »

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
Logged
arturo
Administrator
barcelona

Posts: 2395

Gravatar


WWW
Re: ofxHttpServer
« Reply #4 on: July 17, 2009, 09:54:23 AM »

you need to add the library to the linker settings of your project.  don't remember exactly how you configure this in xcode though.
Logged
Gestalt
Duesseldorf

Posts: 76

Gravatar


Re: ofxHttpServer
« Reply #5 on: July 17, 2009, 01:01:46 PM »

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?
Logged
arturo
Administrator
barcelona

Posts: 2395

Gravatar


WWW
Re: ofxHttpServer
« Reply #6 on: July 17, 2009, 10:05:00 PM »

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
Logged
millermichaelx

Posts: 6

Gravatar


Re: ofxHttpServer
« Reply #7 on: November 10, 2009, 11:49:07 PM »

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;
}
Logged
m9dfukc
Berlin, Germany

Posts: 112

Gravatar

in the search for the absolute.


WWW
Re: ofxHttpServer
« Reply #8 on: February 20, 2010, 11:22:53 AM »

perfect addon  :wink:  ... need it for the exactly same task - transfering images between OF and another app.


thank you very much for this!
Logged

m9dfukc
Berlin, Germany

Posts: 112

Gravatar

in the search for the absolute.


WWW
Re: ofxHttpServer
« Reply #9 on: February 20, 2010, 12:25:20 PM »

ok, also have problems with linking the library in xcode 3.2.1 – can't find "project > settings > linker > other options" … any help would be appreciated.

edit: seems I have found the problem - the compiler throws a error: "/Users/m9dfukc/Documents/Openframeworks/of_preRelease_v0061_osxSL_FAT/addons/ofxHttpServer/libs/microhttpd/lib/linux/libmicrohttpd.a, file is not of required architecture"

... seems to be root of the problem. I will try to compile the microhttp lib for myself.

thanks
m9d
« Last Edit: February 20, 2010, 12:29:19 PM by m9dfukc » Logged

arturo
Administrator
barcelona

Posts: 2395

Gravatar


WWW
Re: ofxHttpServer
« Reply #10 on: February 20, 2010, 12:27:47 PM »

haven't used it very much but i'm almost sure that in xcode youcan just drop the library in your project and it will work.
Logged
m9dfukc
Berlin, Germany

Posts: 112

Gravatar

in the search for the absolute.


WWW
Re: ofxHttpServer
« Reply #11 on: February 20, 2010, 12:32:30 PM »

@arturo


yeah, that's what i did ... seems to be a different problem (see edit of my previous post).


thanks
Logged

arturo
Administrator
barcelona

Posts: 2395

Gravatar


WWW
Re: ofxHttpServer
« Reply #12 on: February 20, 2010, 12:38:14 PM »

yes, you're adding the linux library, you need the osx one. can't remember if it's in the package, if not joshua posted it some posts above ; )
Logged
m9dfukc
Berlin, Germany

Posts: 112

Gravatar

in the search for the absolute.


WWW
Re: ofxHttpServer
« Reply #13 on: February 20, 2010, 01:02:28 PM »

hi arturo - I added the osx one, not the linux lib (downloaded it from joshua) ... also compiled it for myself (took the actual lib from here: http://www.gnu.org/software/libmicrohttpd/ ) - still getting this mysterious warning message  – now: "ld: warning: in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libmicrohttpd.dylib, file is not of required architecture" ... something I'm doing wrong


sorry for my stupidy  :oops:

... will try it again with joshuas version


edit: note to myself: learn the differences between dynamic and static libraries ; )
Logged

m9dfukc
Berlin, Germany

Posts: 112

Gravatar

in the search for the absolute.


WWW
Re: ofxHttpServer
« Reply #14 on: February 20, 2010, 01:32:16 PM »

ok,

very sorry for spamming but I still can' get it up running - and I really don't know what I'm doing wrong ... maybe my lack of knowledge.

my problem:

installed you library, added joshuas compiled osx lib, removed the linux and windows ones.

running into a compiler error stating that "_MHD_... " can't be referenced from ofxHTTPServer.
also getting a waring "in /Users/m9dfukc/Documents/Openframeworks/of_preRelease_v0061_osxSL_FAT/addons/ofxHttpServer/libs/microhttpd/lib/osx/libmicrohttpd.a, file is not of required architecture"


already tried to compile the libmicrohttpd for myself, but that did't change anything.
tips/help would be really appreciated - won't burn more and more in fixing a (hopefully simple) linker error (actually the most irritating part of c++ for me ;)


by the way, I'm on a macbook pro, osx snow leopard, of 061 and xcode 3.2.1

thanks in advance
m9d
Logged

Pages: [1] 2 3 4
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines
kinect

viagra priser