PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|Proxy|HoTTProxy|HoTTProxy.pl =

page 8 of 12



$proxy->push_filter( scheme => 'proxy', request => $requestHeaderFilter );

$proxy->push_filter( request => $requestHeaderFilter );

$proxy->push_filter( mime => '*/*', response => $responseHeaderFilter );

AddInFilters($proxy);

say (sortableDate() . " HoTTProxy $HoTTProxyVersion Started.\n\n",1);

$proxy->start;

sub proxyCookieSupport {
 # If you remove proxy cookie support from the program, remove this too and then
 # the 'ProxyCookiesEnabled' config setting will automatically go to zero
 return 1;
}

sub parseNetscapeCookie {
   my $cookie = shift; # e.g. RCG01lastactivity=1119168277; domain=.homegunsmith.com; path=/; 
expires=Mon, 19-Jun-2006 08:04:37 GMT
          # Note: should *not* have the Set-Cookie: prefix
          
   my $host = shift;  # e.g. www.homegunsmith.com
   my $path = shift;  # e.g. /

   # if (not $cookie =~ m/^Set-Cookie:/i) {
   #  return; # Not a Netscape Set-Cookie header
   # }


   # // ***************  Rule validation for host names  *************** \\
   
   # Host name rules:
   
   # 1. Name must start with a period
   # 2. If name less than 2 periods then .local is appended

   # Rule #1
   if (not $host =~ m/^\./) {
    $host = '.' . $host; # make it so
   }
   
   # Rule #2
   if (periodCount($host) < 2) {
    $host .= '.local';  # See RFC2109 to get an idea of what I'm doing here
   }

   # \\ ***************  Rule validation for host names  *************** //


   if ((not $cookie) or (not $host) or (not $path)) {
    return; # We can't properly figure out the cookie without all these things
   }
   
   # $cookie =~ s/^Set-Cookie://i; # Remove the Set-Cookie: designator
   
   my @nvpair = split(/;/,$cookie); # Split up the name/value pairs.  The first pair must be the 
cookie name and value
   
   my %cookie = ();
   my ($name, $value, $i, $lcname);
   
   # ($name, $value) = split(/=/,$nvpair[0]);
   ($name, $value) = $nvpair[0] =~ m/^([^=]*)=(.*)$/;    # Unlike the previous "split", this 
handles if there are equal signs ('=') embedded in the string
   $name =~ s/\s//g; # remove any whitespace from the name
   $lcname = lc($name);  # we are going to use the lowercase name of the cookie for storage purposes
   
   $cookie{'name'} = $name; # Later specs specify the cookie name is to be case insensitive, so 
when replacing old with new, we'll be case insensitive, but we'll store the case "as sent" so we 
can return it "as sent" in case the application cares.
   $cookie{'value'} = $value;
   
   for ($i=1; $i <=$#nvpair; $i++) {
    # my($name,$value) = split(/=/,$nvpair[$i]);
    my($name, $value) = $nvpair[$i] =~ m/^([^=]*)=(.*)$/;  # Unlike the previous "split", this 
handles if there are equal signs ('=') embedded in the string
    $name =~ s/\s//g; # remove any whitespace from the name
    $name = lc($name); # All of these parameters should have their names in lower case
    if (($name eq 'domain') or ($name eq 'path') or ($name eq 'expires') or ($name eq 'secure')) { 
# Only want the parameters we understand
     if ($name eq 'secure') {  # The 'secure' nv pair isn't really a pair, only the name will 
appear, so we force a 1
      $value = 1;
     }
     $cookie{$name} = $value;
    }
   }

 if (not $cookie{'expires'}) {
  # Give the "session cookie" an expiration date because we don't have control of a "session"
  $cookie{'expiresEpoch'} = time + ($HoTTProxyConfig{'SessionCookieLife'} * 60);
  $cookie{'expires'} = time2str($cookie{'expiresEpoch'});
 } else {
  $cookie{'expiresEpoch'} = str2time($cookie{'expires'});
 }

   ## BBlakley: Note, probably want to throw some sort of log if any rule fails other than 
defaulting rules
=8=

1|2|3|4|5|6|7| < PREV = PAGE 8 = NEXT > |9|10|11|12

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00632191 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)