The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

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:

  1. 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.
  2. 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—
  3. 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.

Obligatory Picture

Trying to get into the festive mood this year

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.