't Bijstere spoor

't Bijstere spoor

A blog about Web development

OS/X WebDAV and Chunked Transfer Encoding

While OS/X's WebDAV implementation is quite slow, it is mostly pretty decent. The client uses the little used Chunked transfer encoding for PUT requests, which allows it to send big files without knowing exactly how big the file is going to be. A request like this looks like this:

PUT /image.png HTTP/1.1
Host: example.org
User-Agent: WebDAVFS/1.8 (01808000) Darwin/10.2.0 (i386)
Accept: */*
X-Expected-Entity-Length: 10316
If: (<opaquelocktoken:44445502-c253-02e6-7198-45b36c96e8c7>)
Connection: close
Transfer-Encoding: Chunked

While this is a perfectly legal HTTP request, webservers choke on it. Both Nginx and Lighttpd respond with HTTP 411 Length Required. This would have been valid for HTTP/1.0 servers, but if they claim to support HTTP/1.1 they must accept these requests.

Apache + mod_php does this fine, but just recently I got a report from someone using Apache + fastcgi + php. In this case the request body never arrived in PHP which can unfortunately result in silent data loss.

So I guess that's a bit of a warning, so far OS/X WebDAV only plays nicely with Apache + mod_php servers.


Upgrading to Snow Leopard adventures

I just got my copy of snow leopard in the mail, so I decided to upgrade my laptop. After doing a full backup, I didn't turn out to be as easy as I thought.

The installation process quickly showed a little yellow triangle, indicating I didn't have any startup disks. I quickly remembered I had a dual boot to Ubuntu, and used Refit, which is basically an alternative boot menu, to get into Linux and the likes.

So I looked up the removal instructions, but unfortunately this didn't change the situation. I then read that OS/X will restore the standard EFI loader (if that's the correct terminology), by opening the Disk Utility, and making the partition slightly smaller and bigger again. Trying this I got an odd error, namely "MediaKit reports no such partition". No dice.

So I ended up booting an Ubuntu Live CD, removing the linux ext3 and swap partitions there. After this was done, I was able to resize the main OS/X partition, which eventually fixed the problem.

If you ran into similar problems, I'm hoping there's enough keywords in here for you to find this solution :).

After all that installing Snow Leopard is a bit of an anti-climax. As advertised, not a lot changed, and I've yet to see a noticeable speed difference. The OS is using less disk-space, but 29 euro is still a high price for a glorified 'rm' statement.

I do notice small notification improvements here and there, and Address Book.app now supports CardDAV, which is nice.


OS/X internet sharing defaults to 192.168.2.* range.

I was stumped, I was trying to hook up a second computer on the internet through ethernet. Normally it's easy enough to just turn on internet sharing. It turns out OS/X always uses 192.168.2.*, which happened to be in the same subnet as the WiFi network.

OS/X provides no way to change this as far as I could tell. Thankfully I was able to change the router's settings. If you ever get into this situation and you're not able to make this change, here's a simple guide to setup internet sharing using the console.


Converting line-endings with ViM

I got my hands on a file containing OS/X line-endings (\r), which needed to be converted into Unix line-endings (\n).

Normally I would just do a simple search and replace, with:

:%s/\r/\n/g

Oddly enough, this actually gave me null-characters (0x00) instead of the expected \n. After some browsing, this seems to be the correct command:

:%s/\r/\r/g

I have no clue why, and this seems wrong to me, as this command should not have any effect (replacing \r with \r). But yea, it worked :S


Flash Uploader on Mac not triggering onComplete event

We have had a whole bunch of issues with the Flash 8 uploader on OS/X in the past. Now its completely broken on leopard, but before we weren't able to do multi-file uploads because the 'onComplete' event wasn't triggered from within flash.

We've been using a (modified) version of SWFUpload and also our Flash applications have had this issue..

Today I read on The Joy of Flex-blog that there's actually a really simple solution to this problem. Have your PHP (or other server-side) simply return some data. Our upload-endpoint normally always returned nothing at all, because it seemed unnecessary, but returning a small body in your HTTP response fixes the issue!

As you can tell, I'm excited.


OS/X terminal settings for linux programmers

Updating the keybindings again for the terminal did the track. I now have working home, end, page-up and page-down keys.

If you don't feel like messing around with the settings, you can download my settings here:

Evert.terminal

It also makes it black on white, and a bit of transparency; if you don't like that, you can always put that back to normal. The old behaviour of the mentioned keys can be used by pressing shift along with the key.


Leopard first impressions and problems

I don't want to sound like I'm complaining too much, because I actually really like the new version of os/x. I wanted to cover a bunch of problems so people might know its not just them.

First, my personal favourite improvements.

The terminal

I'm especially happy that some time was spent improving the terminal application. Half my day I spend in that application, and any small improvement is welcome there. The most important being tabs (yessss) and an always running ssh-agent (which integrates with the keychain).

I ran across a bunch of problems as well ..

Flash upload stops working

Since we deal at FileMobile a lot with uploads of large/huge files.. we use a Flash uploader. It completely stopped working in leopard and from what I hear an update of the flashplayer is in the works.

Windows magically disappear using spaces

Spaces is a nice tool and i feel like it could help productivity.. but when you're switching between a few spaces sometimes windows get completely lost and the applications need a restart to re-appear.

Terminal won't change the background color

I'm fairly sure this has to do with the fact that I used a background image for my terminal in tiger; which is a feature that has been removed in leopard. I really dislike the default black-on-white, but I couldn't change my background color anymore. The solution for this was to simply remove:

Library/Preferences/com.apple.Terminal.plist

From my home directory.

My key-bindings for page-up and page-down are lost in the Terminal.

I haven't felt like trying this yet, but I assume I simply have to follow my previous steps, if not.. I'll post about it later..

Airport up and down

Not sure if this is the OS or the airport, but its been shaky.. Hope this gets improved with an update of some sort.


I fixed home and end on OS/X terminal!

Wow, thats a relieve.. I switched to os/x 4 months ago, and everything is just great..

I must say, I needed a little bit time too get used to most of the things shiflet mentions. But after a few weeks, most of the annoyances he mentions are actually quite intuitive. Except not being able to tab to comboboxes, that is!

My biggest issue has been not being able to use 'end' and 'home' as usual.. especially when your ssh-ing into a linux box (I spend at least 75% of time on a given day on remote linux boxes) this is really annoying..

I actually got used to that after a while.. But now! I found the solution to this problem; and it can be found right here.

Next goal: getting page-up/page-down to work in a remote vim window as expected.