#!/usr/bin/perl # Trim an http transcript, removing things you don't want to play back. # Copyright 2002-2007 Patrick Killelea under the GPL. # You may freely copy and redistribute this file. # Version: Tue Jan 8 15:11:48 PST 2008 # Please write p@patrick.net with improvements. # Documentation below. use bytes; # don't allow unicode crap # Read whole file in single gulp. undef $/; $_ = <>; @units = split(/(.*>>>>>>>>.*\n|.*<<<<<<<<.*\n)/); # shift to ignore everything before 1st request marker. shift @units; # Tack delimiter back on to unit. for ($i = 0; $units[$i]; $i += 2) { push @tmp, $units[$i] . $units[$i+1]; } for (@units = @tmp) { s|.*<<<<<<<<.*?^(HTTP.*?)\r.*(.*).*|<<<<<<<<\n$1\n$2\n\n|smi } for (@tmp = @units) { s|.*<<<<<<<<.*?^(HTTP.*?)\r.*|<<<<<<<<\n$1\n\n|smi } # Remove the thread number and timestamp from request. for (@units = @tmp) { s|.*>>>>>>>>.*?$|>>>>>>>>|smi } print @units; __END__ Usage: trim out.http > trimmed.http The replay command works much better with trimmed http traffic.