Wednesday, August 21, 2024
More unintended consequences of my Apache configuration
Now that mod_blog
supports conditional requests,
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:
- A traditional web form where updates are done via the
POST
method. I don't use this method that often, but I have used it—perhaps less than five times over the past 24 years. - Via email—this was my favorite method until I could no longer email the entries from home. Most, if not all, ISPs now forbid outgoing SMTP traffic from residential connections. Seeing how I check my email on my public server, it doesn't make much sense to use email when I can add an entry—
- As a file, via the command line. This is how I add new posts these days. I write the entry at home, copy the file to the server and then add it via the command line.
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 PUT
method,
would take it down to one command,
even for an image-heavy post like this Burning Down The House Show Bunny and I caught in Brevard 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 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. 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.