##
# Convert string to HTTP::Cookie object
# Only handles a single cookie for now
# If no header - create fake one: "Cookies:"
# cookie :=
# header_id ':' cookie_setting+
# ;
# cookie_setting := name '=' value ('; '| $)
# ;
# name := [^=\s]+
# ;
# value = [^"\s]* | '"' [^"]* '"'
# ;
sub str2cookie_jar { # Returns: HTTP::Cookies object
my $self = shift;
my (
$cookieStr, # as_string() representation
) = @_;
my $cookie_jar = HTTP::Cookies->new();
$self->log("str2cookie_jar: $cookieStr\n") if $DEBUG & 0x04;
if ($cookieStr !~ /([^:]+):/) {
$cookieStr = "Cookies:" . $cookieStr;
}
my ($cookie_header, $cookie_rest) = $cookieStr =~ /([^:]+):\s*(\S.*)/;
die "Bad cookie_header in '$cookieStr'\n" if !defined($cookie_header);
die "Bad cookie body in '$cookieStr'\n" if !defined($cookie_rest);
my %cookieh;
my @cookiesettings = split(/;\s*/,$cookie_rest);
my $version = $self->{cookieVersion};
my $path = $self->{cookiePath};
my $domain = $self->{cookieDomain};
my $key;
my $value;
foreach my $cs (@cookiesettings) {
if ($cs !~ /^([^=]+)=(.*)/) {
if ($cs =~ /^\S+$/) {
$key = $cs; # Just presense
$value = "";
}
else {
$self->error("Bad cookie setting '$cs' in '$cookieStr'\n");
return $cookie_jar;
}
}
else {
$key = $1;
$value = $2;
}
if ($value =~ /^([\'\"])(.*)\1$/) {
$value = $2;
}
$self->log("Cookie: $key=$value") if $DEBUG & 0x04;
$cookie_jar->set_cookie($version, $key, $value,
$path, $domain);
}
return $cookie_jar;
}
####
Wait for 5 seconds
Start IM crs01@edial.com crs02@edial.com
crs01@edial.com uploading Attachment file simpleAttachment.txt
callID: BIM_931_1139835130.033
LWP::MediaTypes::read_media_types: Reading media types from /usr/lib/perl5/vendor_perl/5.8.5/LWP/media.types
LWP::MediaTypes::read_media_types: Reading media types from /home/raysmith/.mime.types
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking qa04.edial.office for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/nfs/admin/public/users/crs/testbuddy/simpleAttachment.txt
HTTP::Cookies::add_cookie_header: path /nfs/admin/public/users/crs/testbuddy/simpleAttachment.txt:/cgi-bin/buddies_attach does not fit
HTTP::Cookies::add_cookie_header: Checking .edial.office for cookies
HTTP::Cookies::add_cookie_header: Checking edial.office for cookies
HTTP::Cookies::add_cookie_header: Checking .office for cookies
LWP::UserAgent::send_request: POST https://qa04.edial.office/cgi-bin/buddies_attach
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 527 bytes
LWP::UserAgent::request: Simple response: Internal Server Error
Warning: crs01@edial.com: uploadAttachment POST https://qa04.edial.office/cgi-bin/buddies_attach %inputs failed
Response:
500
HTTP/1.1 500 Internal Server Error
Connection: close
Date: Mon, 13 Feb 2006 12:52:11 GMT
Server: Apache
Content-Type: text/html; charset=iso-8859-1
Client-Date: Mon, 13 Feb 2006 12:52:12 GMT
Client-Peer: 192.168.80.104:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/ST=MA/L=Waltham/O=eDial/OU=auto-gen/CN=qa04.edial.office/emailAddress=replaceme@localhost
Client-SSL-Cert-Subject: /C=US/ST=MA/L=Waltham/O=eDial/OU=auto-gen/CN=qa04.edial.office/emailAddress=replaceme@localhost
Client-SSL-Cipher: AES256-SHA
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
Title: 500 Internal Server Error
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator,
xxx@yyy.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.
More information about this error may be available
in the server error log.
Request:
POST https://qa04.edial.office/cgi-bin/buddies_attach
User-Agent: libwww-perl/5.79
Content-Length: 313
Content-Type: multipart/form-data; boundary=xYzZY
Display: /content/ENG-US/htdocs/buddies/attachDialogInner.html
Mode: attach
--xYzZY
Content-Disposition: form-data; name="callID"
BIM_931_1139835130.033
--xYzZY
Content-Disposition: form-data; name="file_name"; filename="simpleAttachment.txt"
Content-Length: 78
Content-Type: text/plain
simpleAttachment.txt
Test File for
simpleAttachment.pl BuddiesUsers code.
--xYzZY--
upload attachment failed
DB<1>