Saved by tcpdump

02 Dec 2008

Have you ever written a long post on a forum or a blog, clicked the submit button and got an error message back? Perhaps there was some temporary glitch in the server so your long thoughtful post wasn’t saved, but all too often it’s because your session has expired and you’re requested to log in again. If you click the back button in this situation there is a risk that you will come back to the empty text box you started out with and there is no way to get your post back.

What I have learned to do in these situations is that instead of clicking the back button, I refresh the page. The browser will ask whether you are sure that you want to post the same data again, so the data is obviously still there in the browser’s memory. If you go ahead and try to post again, you may succeed (you do risk a double post if the first post was successful although it looked like there was an error). If the server keeps on giving errors, I have a trick that is quite primitive. I start a network sniffer before I click the refresh button. (If you didn’t know, a network sniffer is a piece of software that saves everything that is transferred over the computer’s network card.) Wireshark is a GUI software that works well. Unix-like systems (including Linux and MacOS X) have a command-line utility called tcpdump. You can invoke tcpdump like this to capture everything that goes over port 80 (the default port for web traffic):

sudo tcpdump -s 0 -A -i en0 port 80 > dump.txt

This will save the data in the file dump.txt. (You may have to replace en0 with whatever the name of your network card is.)

Open dump.txt in a text editor and you should be able to find the text. It will be URL encoded (spaces are shown as “+” and other characters as “%21” etc.), but a good text editor should be able to unescape it. (In TextMate you’ll find URL Unescape in the HTML bundle.) Then you can just save your witty, informative and well-written text to retry the post.

I’d be interested to know if there’s a simpler solution but this one works very well and has saved me a few times.

blog comments powered by Disqus