Now that mod_blog [1] supports conditional requests [2], I thought of the next feature I want to add—PUT support to upload posts.
Currently, mod-blog supports three methods to add new entries:
I suppose there's a fourth way—adding the entry directly to the storage area and updating some files containing metadata, but I'm only mentioning this for completion's sake. I don't think I've ever done this except when I was first developing mod_blog back in early 2000.
The new method I'm looking to support, the HTTP (HyperText Transport Protocol) PUT method, would take it down to one command, even for an image-heavy post like this Burning Down The House Show [3] Bunny and I caught in Brevard [4] a few years ago. Something like:
[spc]lucy:/tmp>put entry *.jpg [spc]lucy:/tmp>
It shouldn't be that hard, as supporting the PUT method is eaiser than POST—it's a single item being uploaded, and no x-www-form-urlencoded or form-data blobs to parse through. It's just the MIME (Multipurpose Internet Mail Extensions) type, content length and raw data to be placed in a file somewhere.
So I start working. I add some minimal support to mod_blog to handle the PUT method. I configure Apache to pipe PUT requests through mod_blog:
#On the development server for now <Directory /home/spc/web/boston/htdocs> ... Script PUT /boston.cgi ... </Directory>
and I write a simple script to loop through the command line to upload each file to the webserver.
And yet, when I attampted to upload an image file, I kept getting a “405 Method Not Allowed.”
Odd.
I just couldn't figure out why.
A single entry? Fine. An entry with multiple text files? Fine. An entry with multiple binary files that aren't images? Fine.
An entry with any type of image file? Not fine at all.
I spent entirely too long on this before I remembered a recent change to the Apache configuration: a rewrite rule that redirected image requests directly to the file system [5]. I then added one more line to the configuration:
<Directory /home/spc/web/boston/journal> ... Script PUT /boston.cgi ... <Directory>
and now things worked as expected.
How much time did I waste on this particular rabbit hole? Don't answer that! I'd rather not know.
[1] https://github.com/spc476/mod_blog