Re: Apache2::Cookie and CGI::Cookie
Randy Kobes wrote: I've been looking at the CGI::Cookie: http://search.cpan.org/~lds/CGI.pm-3.27/CGI/Cookie.pm tests in CGI.pm: http://search.cpan.org/src/LDS/CGI.pm-3.27/t/cookie.t run through apreq/glue/perl using Apache2::Cookie: http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Cookie.pm I think the comparison you are missing is Apache::Cookie. Any chance you could add that behavior to this thread ? It would be nice to have all the apis match, but I don't recall if they ever did. -- Philip M. Gollucci ([EMAIL PROTECTED]) 323.219.4708 Consultant / http://p6m7g8.net/Resume/resume.shtml Senior Software Engineer - TicketMaster - http://ticketmaster.com 1024D/EC88A0BF 0DE5 C55C 6BF3 B235 2DAB B89E 1324 9B4F EC88 A0BF Work like you don't need the money, love like you'll never get hurt, and dance like nobody's watching.
Re: apache module or CGI
Ralf Mattes wrote: On Tue, 2007-03-27 at 00:14 +0200, Issac Goldstand wrote: Sam Carleton wrote: On 3/26/07, Issac Goldstand [EMAIL PROTECTED] wrote: I'd say then that you need to do in on-the-fly with caching. Caching should be pretty easy - just have a static algorithm for determining the name of the cached image and stat it to see if it already exists. If so serve it; if not, reduce the image, save it and then serve. You don't need a separate process if we're dealing with foreground processing. Issac, So if I understand you correctly, you are saying that CGI (I am really leaning towards FastCGI if it isn't hard to setup) will work fine, one request, one process, no problems. And you are saying that the use of a proxy server is over kill? Joe's idea of sending a 404 when the smaller image does not exist is interesting, is that basically what you are suggesting? Correct, although my idea was to have the script stat() the file and determine whether to generate content or not, Yes, but be careful: a simple stat won't be enough - you might end up serving partially generated content. Good point - to get around it, you can write the image to a tempfile on the same partition and then just change the filename or move the file (or hard link the inode to a new file and then remove the original) - that should gie you a more atomic write. while Joe's was to let Apache try to serve the file and generate it if it fails... Same idea, but different implementation. I think proxy is overkill, resource-wise; you're still just as vulnerable to too many concurrent worker threads/processes and have additional overhead of the back-end apache processes in addition. I'd personally go for a C/C++ module for Apache just because my strategy would be to optimize for serving the cached content, and from inside Apache, you can sendfile() the cached images This is a very important point: sendfile is an excellent performance optimization, esp. if you predict that an image is served much more often than it's generated (and iff not you might not bother to cache anyway). - if the images need to be generated, you can do that either from inside the same module or pass that on to an system()ed process. I see it as a tradeoff: with a subprocess, you'll need to pay with the extra overhead of the additional process; and 5-7 more file descriptors ... that's part of the overhead I meant. descriptors, a bit of ram, cpu cycles to fork and then exec, etc however, with a module (either a C module for apache or fastcgi) you gain the overhead of keeping imagemagick in memory all of the time. Well, on most OSs that's rather cheap. Shared objects are mapped only once and shared between instances. No need to worry. He said he was going to static link it, so IIRC, it's not going to share the code between processes... Cheers, RalfD Issac
Re: The best practice to definitevely read post data
If your post data is multipart/form-data or application/x-www-form-urlencoded, consider using libapreq (http://httpd.apache.org/apreq/) which will do the heavy lifting for you quite nicely... Issac Thib wrote: Hi, I'm writing a new apache module to handle post data and to generate a response. I'm using a handler, read post data with the methods ap_setup_client_block, ap_should_client_block and ap_get_client_block and It works correctly However, I ask myself about the best way to read post data ( with brigade and buckets for example ? ) Thanks for your help. Thibaud PS : Here an example of how I read post data. ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK); char buffer[1024]; if ( ap_should_client_block(r) == 1 ) { while ( ap_get_client_block(r, buffer, 1024) 0 ) { ap_rputs(Reading in buffer...br,r); ap_rputs(buffer,r); } } else { ap_rputs(Nothing to read...br,r); }
Re: how to get started?
You may need to do apxs -llibhttpd -llibapr-1 -llibaprutil-1 -c ... I've noticed that libs aren't handled properly lately... Sam Carleton wrote: Ok, I have apxs installed!! I have created a basic project called fancy_image_handler, when I follow the instructions in the comment of the mod_fancy_image_handler.c, here is what I am getting: D:\Temp\fancy_image_handlerapxs -c -i mod_fancy_image_handler.c cl /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -IC:\Apache2.2\include /c /Fomod_fancy_image_handler.lo mod_fancy_image_handler.c mod_fancy_image_handler.c link kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:C:/Apache2.2\lib /out:mod_fancy_image_handler.so mod_fancy_image_handler.lo Creating library mod_fancy_image_handler.lib and object mod_fancy_image_handler.exp mod_fancy_image_handler.lo : error LNK2001: unresolved external symbol [EMAIL PROTECTED] mod_fancy_image_handler.lo : error LNK2001: unresolved external symbol [EMAIL PROTECTED] mod_fancy_image_handler.so : fatal error LNK1120: 2 unresolved externals apxs:Error: Command failed with rc=6291456 . By the way, thanks a million for getting me this far! I really appreciate it! Sam
Re: The best practice to definitevely read post data
Hi, Thanks for your response. The post data I must read is pure xml. If I understand well the doc of apreq, it handle data parsing application/x-www-form-urlencoded and multipart/form-data. So with apreq, can I read the post data ? Best regards, Thibaud 2007/3/27, Issac Goldstand [EMAIL PROTECTED]: If your post data is multipart/form-data or application/x-www-form-urlencoded, consider using libapreq (http://httpd.apache.org/apreq/) which will do the heavy lifting for you quite nicely... Issac Thib wrote: Hi, I'm writing a new apache module to handle post data and to generate a response. I'm using a handler, read post data with the methods ap_setup_client_block, ap_should_client_block and ap_get_client_block and It works correctly However, I ask myself about the best way to read post data ( with brigade and buckets for example ? ) Thanks for your help. Thibaud PS : Here an example of how I read post data. ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK); char buffer[1024]; if ( ap_should_client_block(r) == 1 ) { while ( ap_get_client_block(r, buffer, 1024) 0 ) { ap_rputs(Reading in buffer...br,r); ap_rputs(buffer,r); } } else { ap_rputs(Nothing to read...br,r); }
Re: The best practice to definitevely read post data
You could, but you'd need to write your own parser, which I'm not sure you'd want to do... Thib wrote: Hi, Thanks for your response. The post data I must read is pure xml. If I understand well the doc of apreq, it handle data parsing application/x-www-form-urlencoded and multipart/form-data. So with apreq, can I read the post data ? Best regards, Thibaud 2007/3/27, Issac Goldstand [EMAIL PROTECTED]: If your post data is multipart/form-data or application/x-www-form-urlencoded, consider using libapreq (http://httpd.apache.org/apreq/) which will do the heavy lifting for you quite nicely... Issac Thib wrote: Hi, I'm writing a new apache module to handle post data and to generate a response. I'm using a handler, read post data with the methods ap_setup_client_block, ap_should_client_block and ap_get_client_block and It works correctly However, I ask myself about the best way to read post data ( with brigade and buckets for example ? ) Thanks for your help. Thibaud PS : Here an example of how I read post data. ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK); char buffer[1024]; if ( ap_should_client_block(r) == 1 ) { while ( ap_get_client_block(r, buffer, 1024) 0 ) { ap_rputs(Reading in buffer...br,r); ap_rputs(buffer,r); } } else { ap_rputs(Nothing to read...br,r); }
Re: apache module or CGI (conclusion)
Folks, I want to thank all three of you for your time, thoughts, and input on this matter. I have reached a conclusion... Drum role please It will be a apache module!!! In the end, it came down to portability. I realize that either way I go, I need to be using APR and using apxs, it does appear that an apache module is actually easier to implement. I got the skeleton up and running last night! On my nightly walk I started to think of the possibilities now that I am in the world that I know and love: C/C++. I realized a way to implement the whole web solution in this module, but there are more infrastructure questions I have about how to tell the different pages apart. With the current PHP code, I have two different php pages: index.php: It has two looks, one where it shows thumbnails, another where it shows one larger image. Both pages have parameters passed to via the GET method. imageHandler.php: Given the correct parameters via a GET, it will downsize the image and send it out. My first question is, in an apache module, are there tools to get at the parameters passed to the module or will I still need something like cgic to get at them easily? Second, right now the URL looks like I am using gets, I *THINK* I would like to change that so it simply looks like a path: Rather then the current: index.php?fldoid=f50b8377-d1cf-4407-bb59-a86ae7804d5cimgoid=DSC_8912 I would like to see something like this: index.php/f50b8377-d1cf-4407-bb59-a86ae7804d5c/DSC_8912 I do recall seeing something, in years gone by, about how apache can do this type of thing and convert it back to a normal GET for the script. With a module, do I lose this feature and have to simply parse it myself? More importantly, lets say my module is called mod_coolapp and when I have it installed, you get to it at /coolapp. I want /coolapp to be the equivalent to the index.php and then have say, /coolapp/images be the same as imageHandler.php. Is there any trick to knowing which page is being requested or is it simply a matter of doing a string compare to see if the first part of the string passed the actual URL (/coolapp/) is images? Oh, one final question. I am going to set things up so my customers have great flexibility in what the web page actually looks like. The module will read in a template file to get what the out side, HTML wrapper is and then will call different XSLT scripts to actual transform the XML the module creates into HTML. Is there any standards as to where these resource files should be located? Sam
Re: Why my module is increasingly slow?
Thanks for help. I check for socket in TIME_WAIT and they are up to 10 000 ! Moreover, my module must call a soap server to provide data to generate the response. So each time the client make a request, 2 sockets fall in TIME_WAIT. I'm going to see if I can reduce TIME_WAIT parameter on my system (Linux RedHat AS 3.0) and if I can keep connected to my soap server between two requests. Thanks for this help. I send you news quickly if it works or not. Best regards, Thib 2007/3/27, Dr. Peter Poeml [EMAIL PROTECTED]: On Tue, Mar 27, 2007 at 03:21:18PM +0200, Thib wrote: Hi, I almost finished writing my module and made some benchmarks to check performance. I was quiet suprise by what happen. I used JMeter to send HTTP Post request to my module. I ran 5 parallel threads which sent 5000 requests each in series. At the beginning the performance are near 500 request per second but decrease quickly to finish at 250 req/s. I don't understand why performance decrease... I check undelivered memory structures but all look like fine. Anyone has ever meet this kind of problems ? You may want to check for sockets in wait state (netstat -tupan | grep TIME_WAIT). If they accumulate, you can end up in a situation where free socket become scarce. This will also be noticeable by outliers in the response time data. Regards, Peter -- SUSE LINUX Products GmbH Bug, bogey, bugbear, bugaboo: Research Development A malevolent monster (not true?); Some mischief microbic; What makes someone phobic; The work one does not want to do. From: Chris Young (The Omnificent English Dictionary In Limerick Form)
Re: how to get started?
On Tue, 2007-03-27 at 10:58 -0400, Sam Carleton wrote: On 3/27/07, Ralf Mattes [EMAIL PROTECTED] wrote: On Mon, 2007-03-26 at 22:05 -0400, Sam Carleton wrote: Ok folks, I am developing on Windows. I have VC6, VS2005, and Cygwin installed. I would prefer ot use VS2005, but VC6 will work, Cygwin is a last resort, VERY last resort. I first thought I would try Ralf's advice of running apxs -g -n fancy_image_handler, but I cannot find apxs on my Windows machine. Oh, I'm terribly sorry. I only recalled on my way home that you're running on Windows. Not a problem I got it worked out;) I can't comment at all on Windows development - never done it. Iff you want your module to run on Unix/Linux as well it might be a good idea to install VMWare Player and live images for Linux(Ubuntu), Solaris and NetBSD/OpenBSD. Oh, I have lots of *NIX machines to pick from, I have a OpenBSD machine (my firewall), Solaris 8, and a SuSE Linux, no need for VMWare. Good. Still - the virtual testserver thing really grew on me: I have a clearly defined build/test environment (ever been bitten by a missing library that was never detected because it happend to be installed on you test system?). There are two issues, equally big, in terms of me doing the development on anything other then Windows: 1: The GUI frontend to the system is all 100% Windows right now, even though the web side can stand on it's own, it would be a pain to have to go back to windows all the time to change the data feeding the kiosk. 2: I know the tools in Windows to do C/C++ development, been using them for over a decade now. I have never developed in *NIX, so there is most definitely a learning curve. Definitely. I'd dread to heve to learn Windows API and frameworks. The way I see it, I will make my best effort to keep the module platform neutral. I am thinking about taking the time to learn how to setup the module with, I think it is called, automake, so that I can see if I can get it to compile and run on one of the other platforms I have, but if it takes too much time, I am willing to shelve it for now, it just means there might be more work later to fix the bugs when I take the GUI cross platform. Can anyone point me to some good, quick and easy documentation to setup an automake project? You mean 'automake the BEAST' ? :-) Gosh, _that's_ a real monster. I'd start with the automake book: GNU Autoconf, Automake, and Libtool, by Tromey et al. But beware: utomake is a moving target and has changed since the book was written ... Unless you need some fancy system dependent functionality and you stick to libapr for portability you might just copy/morify the automake setup of an existing module. Cheers, Ralf Mattes Sam
Re: how to get started?
On 3/27/07, Ralf Mattes [EMAIL PROTECTED] wrote: Oh, I have lots of *NIX machines to pick from, I have a OpenBSD machine (my firewall), Solaris 8, and a SuSE Linux, no need for VMWare. Good. Still - the virtual testserver thing really grew on me: I have a clearly defined build/test environment (ever been bitten by a missing library that was never detected because it happend to be installed on you test system?). Too true, too true. I use Microsoft Virtual PC to test installs in Windows. I would like to get VMWare, but I don't have the $$$ for it right now. My main point is that I can, general speaking, test to make sure my code will run and work in the *NIX world, fore I have a lot of it around me. Before I ever where to ship a *NIX version, I will have VMWare and will use it for the final testing. In my first job I wrote and tested the installs, prior to virtual PCs. The *ONLY* safe way to really test a install was to wipe the hard drive and reinstall the OS. Microsoft has some tools to speed the process up, to a degree, but what a pain and a HUGE time sink. Today I have my virgin config in a virtual PC and simply don't apply changes, got to love it!! 2: I know the tools in Windows to do C/C++ development, been using them for over a decade now. I have never developed in *NIX, so there is most definitely a learning curve. Definitely. I'd dread to heve to learn Windows API and frameworks. I am going to have to learn it before this is all done, because it *IS* going cross platform, it will be interesting (if I am still doing development at that point in timegrin). You mean 'automake the BEAST' ? :-) Gosh, _that's_ a real monster. I'd start with the automake book: GNU Autoconf, Automake, and Libtool, by Tromey et al. But beware: utomake is a moving target and has changed since the book was written ... Unless you need some fancy system dependent functionality and you stick to libapr for portability you might just copy/morify the automake setup of an existing module. Good to know, thanks! Sam
Re: apache module or CGI (conclusion)
On 3/27/07, Issac Goldstand [EMAIL PROTECTED] wrote: More importantly, lets say my module is called mod_coolapp and when I have it installed, you get to it at /coolapp. I want /coolapp to be the equivalent to the index.php and then have say, /coolapp/images be the same as imageHandler.php. Is there any trick to knowing which page is being requested or is it simply a matter of doing a string compare to see if the first part of the string passed the actual URL (/coolapp/) is images? You're going to want to parse/compare the string. The Right Way(tm) to do this would probably be during the translate_name or possibly map_to_storage hooks to separate the URI mapping logic from the actual response processing logic. You totally lost me with the translate_name and map_to_storage, I will have to do some reading on it. Oh, one final question. I am going to set things up so my customers have great flexibility in what the web page actually looks like. The module will read in a template file to get what the out side, HTML wrapper is and then will call different XSLT scripts to actual transform the XML the module creates into HTML. Is there any standards as to where these resource files should be located? I have thought of another question centered around the above concept of making the site configurable: Is the above approach the best and most flexible approach? Is there a better approach? Sam
Re: reference out of date?
Hi, It's a very useful book, even though it predates apache 2. You will need to supplement it (with a few articles on converting modules from apache 1.3 to apache 2, and with the doxygen pages for apache 2 and apr, or with Nick Kew's new book), but I still find it to be an indespensible reference to the Apache API. JD On Mar 27, 2007, at 1:04 PM, Sam Carleton wrote: Many moons ago, around 2001 I believe, I purchased the book Writing Apache Modules with Perl and C by Lincoln Stein and Doug MacEachern. I have not dug it up yet, but I am guessing that it was written for Apache 1.x. For my needs, handling basic requests, will it be out of date? Sam
Re: reference out of date?
On Tue, 2007-03-27 at 13:20 -0700, John David Duncan wrote: Hi, It's a very useful book, even though it predates apache 2. Hmm, it sure was a very useful book until recently - since it pretty much was _the_ only book on Apache module development. I was always amazed at the lack of documentation for Apache2 module developers. Go get a copy of Nick's book fast. This is the best (and only) you can get for Apache2 -- if you feel like it you might want to read parts of Writing Apache Modules .. (esp. the introduction chapters and the smallish part on C at the end) but Nick's tome is pretty much a must. If some nitts and picks with that book but there is a wealth of information in it - don't waste your time reading partially out-of-date documentation fragments from the web. Just my 0.01 € Cheers, RalfD You will need to supplement it (with a few articles on converting modules from apache 1.3 to apache 2, and with the doxygen pages for apache 2 and apr, or with Nick Kew's new book), but I still find it to be an indespensible reference to the Apache API. JD On Mar 27, 2007, at 1:04 PM, Sam Carleton wrote: Many moons ago, around 2001 I believe, I purchased the book Writing Apache Modules with Perl and C by Lincoln Stein and Doug MacEachern. I have not dug it up yet, but I am guessing that it was written for Apache 1.x. For my needs, handling basic requests, will it be out of date? Sam
Can't locate ModPerl/MM.pm
Hay folks, I am trying to get libapreq2 installed on my Windows machine. I fixed the bug in the Makefile that was looking for libapr.lib rather then libapr-1.lib, but I am stumped on the error Can't locate ModPerl/MM.pm Here is the whole thing: C:\Perl\bin\perl.exe Makefile.PL Can't locate ModPerl/MM.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib.) at Makefile.PL line 2. BEGIN failed--compilation aborted at Makefile.PL line 2. NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x2' Stop.
Re: mod_ftp, status and progress?
Hi, is it possible that with your last commit changes you forgot to update mod_ftp.h too? I tried to compile for NetWare, and needed this in order to get it compiled: --- mod_ftp.h.orig Tue Mar 27 13:27:22 2007 +++ mod_ftp.h Tue Mar 27 13:49:04 2007 @@ -250,6 +250,8 @@ const char *readme; const char *path; int readme_isfile; +apr_fileperms_t fileperms; +apr_fileperms_t dirperms; }; /* also want to ask if it is ok when I add NetWare makefiles? Guenter.
Re: mod_ftp, status and progress?
Guenter Knauf wrote: Hi, is it possible that with your last commit changes you forgot to update mod_ftp.h too? Feh - yup. My bad - thanks! also want to ask if it is ok when I add NetWare makefiles? Be our guest :) Keep it mind it's ment to be built against installed httpd, or built in tree (within modules/ftp/) as desired.
Re: mod_ftp, status and progress?
Hi, also want to ask if it is ok when I add NetWare makefiles? Be our guest :) Keep it mind it's ment to be built against installed httpd, or built in tree (within modules/ftp/) as desired. sorry, but for now only inside tree; anyway all NetWare compile is sort of cross-compile, and way more complex than anything other I came over. No paths are really fix, nor does our installed Apache ship with the headers / libs by default; and the NetWare build system isnt really prepared for such. Although we can create an 'Apache SDK' this lacks currently of the needed files which all makefiles include, and so a makefile which works with that looks completely different. I will though look if I can fix that over the time with the SDK, and then update the makefiles. Guenter.
reference out of date?
Many moons ago, around 2001 I believe, I purchased the book Writing Apache Modules with Perl and C by Lincoln Stein and Doug MacEachern. I have not dug it up yet, but I am guessing that it was written for Apache 1.x. For my needs, handling basic requests, will it be out of date? Sam
[PATCH 30730] mod_actions and Server-Status (Patch review request).
Hi, I am Basant and I work for Sun Microsystems Inc. in web tier group. I have submitted the patch for 30730. Bug Id : 30730 http://issues.apache.org/bugzilla/show_bug.cgi?id=30730 Summary : mod_actions and Server-Status Patch uri : http://issues.apache.org/bugzilla/attachment.cgi?id=19706 I would like to make a humble review request for the patch. Thanks and Regards, Basant.