klortho: Much Accomplished, Much Remaining
Thursday, March 12, 2009
Okay, the latest: I’ve fixed the incomplete headers problem, and found a solution to proxying non-XML resources: not to do it at all!
Here’s the way klortho now behaves. It parses the request URL, does a HEAD request on it with the original HTTP headers from the user’s browser, and then takes 1 of 3 actions. If the returned status code is anything other than “200 OK”, it returns the headers it receives. If it gets a “200 OK”, but the “Content-Type” is anything other than “application/xml” or “text/xml”, it sends a “301 Moved Permanently” status, with a “Location” header pointing the user’s browser to the URL parsed from the “PATH_INFO”. This tells the user’s browser that klortho is not interested in brokering this request, and to kindly just get the resource directly from now on, thankyouverymuch. Only if it has a “200 OK”, and the right XML content type does it go ahead and retrieve the body of the response, and process and return it.
Still unfinished:
- POST requests. This is a biggie. If the checks succeed, klortho will have to pass in the POSTed data it receives. libCurl has a good tutorial on this. It’s should be straightforward.
- Some response headers may need to be adjusted on the way out, the ones that relate to proxying.
- Authentication will need to be transparently passed through
Keep checking back, I’ll keep you updated. If you feel like contributing, let me know.
The Links:
More progress, more setbacks on klortho
Friday, March 6, 2009
I have a version of klortho that’s able to parse its PATH_INFO, grab the XML that’s located there, and apply the transformation that’s in the processing instruction, if such exists. That’s cool.
I’ve been using this to work with my python band name generator, and I can get random band names to show, and that’s really great, because I can use the needs I discover while working on this band name program to decide which as yet unimplemented parts of klortho I’ll need to implement, which brings us to my roadblock.
I’m writing the python script (called “Rate”) that will take in POSTed parameters to update the ratings for all the words in the previously displayed band name, and then redirect back to “Show”. klortho needs to do two things that it can’t do yet in order for this to work: it needs to understand POSTed data, and pass it to the sub-request, and it needs to recognize redirect status codes from the sub-request, and pass them back out, along with the appropriate headers.
I started small and modest. “Rate” just issues a redirect to “Show”. If you call the script directly, it works. Nothing I try in klortho will pass that redirect out. I run into a brick wall of of “500 Server Error”. The server error log reliably reports that FasctCGI is complaing that I’m sending incomplete headers. Is it a Dreamhost server config issue? What’s going on? What do I try next to learn more about what’s really happening?
I see two roads, and I may follow them both at the same time. I can create a little dummy FastCGI in c, that does nothing but issue hard-coded redirects. I’d leave out all the other things that klortho is doing, and tweak away at the stripped down version until I get it right, then put what I’ve come up with back into klortho. The other idea I’ve had is to write another version of klortho from scratch, and concentrate on acting as a fully transparent proxy, which will pass all the appropriate headers in and out, handle authentication and POST data and file uploads and any status code the sub-request might throw at it, and then add the XSLT transformations back into it.
Been Sick
Tuesday, February 17, 2009
Was sick all last week. Didn’t feel like posting, didn’t feel like doing much on my programming projects.
I did fiddle with klortho a little, got rid of the segfault, but still haven’t been able to get it to actually serve up a page on Dreamhost. Environment variables/dynamic linking maybe? that’s my next avanue of investigation.
Dangerous
Saturday, February 7, 2009
I don’t get it. How can a language as dangerous and fussy as C have been used to create so much cool stuff? Linux, BSD, Apache, perl… you get the idea. I got spoiled by perl, python, lisp and other langauges where what you type generally does what you mean. C is like you’re stupid friend, who does what you say, literally, whether it makes any sense at all or not.
Band Name Generator
Friday, January 23, 2009
I used to have a cool little program I wrote on the web, called the band name generator. I’d gone through a couple different versions, adding features, and had a lot of fun writing it. Then I lost interest, changed internet service providers, and let it just go away.
It’s coming back. Woo Hoo. I’ve found it’s been a really great way to get myself motivated to learn new ways of doing things. I can take a concept that I’ve thought about in deep detail, and re-imagine it in terms of the latest ideas that happen in web programming.
The next set of “buzzwords du jour” will be “RDF”, “SPARQL”, and “ontology”. That will mean BUPKUS to most of you, but I’m excited.
Progress on Klortho!
Thursday, January 15, 2009
Klortho
I got a small C program working, that acts as a FastCGI, fetches XML with libcurl, extracts the xml-stylesheet PI from the result and applies the transformation using libxml and libxslt, then returns HTML to the browser. Yay!
Still TBD:
- extract all headers, and pass them through libcurl
- handle POST, HEAD and PUT
- handle HTTP authentication
- pass response headers through transparently
- proxy non-XML requests, and XML without a stylesheet PI
- clean up the C
- fix the autoconf/automake stuff
- test portability
Still, I’m pleased, and inspired to actually do more work on this.
Anyone want to help?
Emerging from the vapor
Monday, July 9, 2007
Klortho as been a work-in-progress in my mind since 2004 or so, but nothing beyond the creation of a sourceforge project has really happened with it. Well, I finally got around to making something happen: I made a small perl fastcgi script for doing automatic XSLT transforms, and added some .htaccess/mod_rewrite plumbing to my www.unfoldedmind.com account. (It’s on a shared host where I can’t use mod_transform the way I wanted to). after that, I was able to whip up a rudimentary main template, and add a couple xml pages, with their own stylesheets.
There is not much to see on the surface at present, and there may not be for a while, but I’m pleased to have enough of a scaffold in place to start working on the harder parts.
These harder parts include:
- Getting the fastcgi to pass GET, POST and COOKIE data to the underlying request
- Building data models with Berkely DB/XML
- Getting Haskell and Lisp to talk to the C++ API for BDB/XML
- Learning enough Haskell and Lisp to make working this way fun, and not frustrating
Anyone want to help?
