Click here to check if anything new just came in.
April 13 2012
April 06 2012
April 04 2012
March 25 2012
March 18 2012
March 16 2012
March 13 2012
February 26 2012
ETag header missing in HTTP No Content responses in Internet Explorer
If you’re one of that exceedingly rare breed who regularly check or subscribe to my blog, you probably want to give this post a miss. This one is more for people who find me through Google. A specific solution to a specific, geeky, problem.
Background
First a little scene setting…
Server side
I have a REST API that uses ETags for, amongst other things, concurrency control. That is, the version of an entity is (opaquely) identified by an ETag. You need to specify that ETag when you try and make any changes to that entity. If someone else changes the entity before you do, your ETag won’t match, so your update will fail, and you won’t unintentionally roll-back their change.
The REST API returns no content (HTTP 204) in response to a successful PUT request to edit an entity, and includes the new ETag representing the version of the updated entity.
Client side
I have a Dojo web tool that uses xhr.put to submit edits to the REST API. In order to make further subsequent edits to an entity without reloading the page, it stores the ETag that it gets back in the response header after every PUT.
The problem
In short, Internet Explorer.
In more detail, it seems that there is a bug in Internet Explorer when it gets a 204 no-content response to an xhr request from Javascript.
IE does drop whatever it uses to store the response content. Unhelpfully, it also drops all of the response headers.
This means my client side Javascript doesn’t get the updated ETag returned by the server.
It means my Javascript can make one update to the entity. After this, it doesn’t have the correct ETag required to make any subsequent updates.
This bug seems to be present on all versions of IE that I tried, including the latest-and-greatest.
A workaround
One way of handling this without needing to modify the REST API is to extend the behaviour of xhr.put so that, when running on Internet Explorer only, it follows up a successful PUT with a HEAD call to the same entity. This is just enough to get the updated response headers – to fetch the updated ETag that IE dropped from the PUT.
By daisy-chaining the two requests, this is invisible to code that calls xhr.put.
This is implemented as a module myproject/xhr to use in place of dojo/_base/xhr. It behaves in the same way as dojo/_base/xhr, with the exception of this additional workaround.
define(["dojo/_base/declare", "dojo/_base/xhr", "dojo/_base/sniff", "dojo/_base/lang"],
function (declare, xhr, sniff, lang) {
function myXhr() {
//
// if we are using a JSON with ETags handler, then we are interested
// in the the entity tag contained in the response header of the POST/PUT
// requests
//
// however, on Internet Explorer, this response header is missing,
// because of the bug described at http://www.enhanceie.com/ie/bugs.asp
// (IE0013: IE XMLHTTP implementation turns 204 response code into bogus 1223 status code)
// so we have to perform an additional GET to fetch the updated
// entity tag.
//
// this bug is present on IE7-IE9 so we do this for any version of IE
//
this.put = function (request) {
if (sniff("ie")) {
return xhr.put.apply(this, arguments).then(lang.hitch(this, function(response){
delete request.headers['If-Match'];
return xhr("HEAD", request);
}));
}
else {
return xhr.put.apply(this, arguments);
}
};
};
myXhr.prototype = xhr;
return new myXhr();
});
Postscript
Oh IE, for crying out loud. How much more could we get done if we didn’t have to spend so much time working around your little quirks?!
Feed footer idea nicked from 43 Folders using the FeedEntryHeader WordPress plugin.
February 24 2012
Posting to IBM Connections from WP7
IBM Connections is something we use at work: an internal, intranet-hosted social network for work stuff.
I use stuff like the wikis, file sharing, and bookmarks, quite a lot. But I don’t make status updates as often as I could.
I wonder if that’s because I couldn’t do it from my phone? I know that I certainly started using Facebook a lot more since getting a phone with support for posting to facebook and twitter built-in.
So I set up a way for me to post to Connections from my phone with just one tap on the home screen.
Well, one tap, plus all the taps to actually type the status message… plus another tap on the Send button. But you get the idea.
I’ve written up how I did it. This is on our intranet, as it uses an approach which only applies to our deployment and wouldn’t be relevant to anyone outside.
Although I’ve done it for WP7, the basic idea should apply to Android and iPhone, so if you’re interested don’t let that put you off.
The question is, will this get me updating my Connections status more often?

Feed footer idea nicked from 43 Folders using the FeedEntryHeader WordPress plugin.
February 18 2012
A week off for half-term
This week has been school holidays in Hampshire, so I took a week off to entertain the rampaging monsters otherwise known as my children.
As always, it’s been a fun mix of things. With a three year old and a seven year old, the general plan is to try something a bit different every day so they’re not bored by the end of the week.
We did a few arts and craft things. We made our own candles, melting down candle wax chips from Hobbycraft in a saucepan, adding colouring and pouring them into moulds. We did some sewing, making stuff like animal-shaped cushions.
We spent an afternoon mucking about with a camera and a microphone. Faith loves singing into a small USB microphone we’ve got, so we recorded her singing some of her favourite songs. Grace tried making a stop motion animation using her Sylvanian Families. It ended up being 25 seconds long, but between taking all the photos, and recording the voices and sound-effects, it took her ages!
Given Grace’s recent decision that she wants to be a scientist when she’s older, we tried to fit a few science activities in the week. I’ve blogged about two of the most interesting ones already – making a voice box out of a balloon and straws, and making an evaporograph from a sandwich bag, rubber bands and a plastic cup. We also tried a few other random bits and pieces, like making a race track for balloons from cheap thread and racing them across the bedroom.
The kids both love to eat, so we did a few food-related things. The all-you-can-eat buffet at the new Chinese restaurant in town was a good excuse for trying out a bunch of new food, as well as working on our chopsticks technique.
We made some odd things, like spaghetti threaded through hot dogs, and hand-shaped jelly using rubber gloves as moulds. We also tried some more normal things, like getting the kids to make their own pizzas, and squeeze their own orange juice.
The weather was rubbish, but we managed to do some outside stuff. We found a couple of geocaches – although the girls call it treasure-hunting in the woods! We also did the usual, like several trips to the playground, and rides on their bikes and scooters. Less said about Grace’s attempt to teach me to use a skipping rope, the better.
Because of the weather, we did more indoor-but-active stuff – a morning at the soft-play centre, a couple of trips to the swimming pool, as well as taking Grace to her usual gymnastics class at Knightwood.
The rest of the week was filled with random bits and pieces around the house: reading books together, playing board games (the favourite this week ended up being Marble Run, with Junior Scrabble in second), and watching a lot of Doctor Who with Grace. Thanks to LOVEFiLM’s streaming on the XBox, we had a movie night with popcorn and Gnomeo and Juliet (great film – a kids film that’s fun for adults, too). And we had Grace’s friend over for a sleepover another night.
I managed to avoid thinking about work too much, but did spend a few evenings writing a presentation I’ve got to give this Wednesday. I’ve been using Prezi since 2009, so have been keen to try something new. I used this as a chance to write a presentation in HTML with CSS transforms for the transitions. I tried a few techniques but settled on impress.js, a cool 3D presentation tool. I’ll have to see how it works out on an audience on Wednesday.
Amy was pretty ill, so I had the TV to myself for most of the week. Thanks to Netflix on the XBox, I finally watched Season 2 of Dollhouse (awesome!) and played a lot of Modern Warfare 3 (I finally prestiged!)
That was my week. On Monday, I’m back to work. A chance to relax and make up for a week with nowhere near enough coffee.
(Oh – by the way, I should credit Roo with giving me the idea for a post looking back with rows of small square photo thumbnails, from his post this week on getting a very exciting new job)
Feed footer idea nicked from 43 Folders using the FeedEntryHeader WordPress plugin.
February 17 2012
Making an evaporograph
It’s still half-term, so time for another random “what can I do with the kids that’s vaguely science-y and only needs stuff that we have around the house”.
We made an evaporograph.
No, I’d never heard of it before, either.
But it was pretty cool which is why I’m blogging it myself instead of leaving Grace to write it up
It worked like this…
We put water in a plastic cup, and put a sandwich bag over the top, wrapping rubber bands around it to keep it in place. Then we left it for a while (while we went to play ballon racing!) so the water would go to room temperature.
Then it was ready to go.
We briefly pressed something cold against the bag plastic. It made the water vapour in the inside of the cup condense, and collect on the underside of the plastic – leaving an imprint of whatever we pressed.
We got the best results with cold coins (coins we’d left in the freezer for a bit).
It looked seriously impressive, but my camera sucks at macrophotography (or I do?) and struggled to focus on transparent plastic, so you’ll have to take my word for it. The photos really don’t do justice to the imprints we made!
Big thanks to Spark, Bang, Buzz where I got the idea for this from.
Feed footer idea nicked from 43 Folders using the FeedEntryHeader WordPress plugin.
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...


























