+2009-08-27 Micah Cowan <micah@cowan.name>
+
+ * http.c (gethttp): Make sure Wget heeds cookies when they
+ are sent with a 401 response; or any other sort of response for
+ that matter (#26775).
+
2009-08-19 Micah Cowan <micah@cowan.name>
* openssl.c (ssl_check_certificate): Only warn about an attack if
}
}
+ /* Handle (possibly multiple instances of) the Set-Cookie header. */
+ if (opt.cookies)
+ {
+ int scpos;
+ const char *scbeg, *scend;
+ /* The jar should have been created by now. */
+ assert (wget_cookie_jar != NULL);
+ for (scpos = 0;
+ (scpos = resp_header_locate (resp, "Set-Cookie", scpos,
+ &scbeg, &scend)) != -1;
+ ++scpos)
+ {
+ char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie);
+ cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port,
+ u->path, set_cookie);
+ }
+ }
+
if (keep_alive)
/* The server has promised that it will not close the connection
when we're done. This means that we can register it. */
hs->newloc = resp_header_strdup (resp, "Location");
hs->remote_time = resp_header_strdup (resp, "Last-Modified");
- /* Handle (possibly multiple instances of) the Set-Cookie header. */
- if (opt.cookies)
- {
- int scpos;
- const char *scbeg, *scend;
- /* The jar should have been created by now. */
- assert (wget_cookie_jar != NULL);
- for (scpos = 0;
- (scpos = resp_header_locate (resp, "Set-Cookie", scpos,
- &scbeg, &scend)) != -1;
- ++scpos)
- {
- char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie);
- cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port,
- u->path, set_cookie);
- }
- }
-
if (resp_header_copy (resp, "Content-Range", hdrval, sizeof (hdrval)))
{
wgint first_byte_pos, last_byte_pos, entity_length;
+2009-08-27 Micah Cowan <micah@cowan.name>
+
+ * run-px: Added Test-cookies.px, Test-cookies-401.px
+
+ * Test-cookies.px: Basic testing to make sure Wget doesn't send
+ cookies; no path/domain checking.
+
+ * Test-cookies.px: Test to make sure Wget heeds cookies when they
+ are sent with a 401 response (#26775).
+
+ * HTTPServer.pm (send_response): Don't try to substitute port in
+ response body, if there isn't one.
+ (verify_request_headers): Avoid uninitialized warning when an
+ expected header isn't provided by Wget.
+
2009-07-27 Micah Cowan <micah@cowan.name>
* Test-restrict-ascii.px: New.
next;
}
# fill in content
- $content = $self->_substitute_port($content);
+ $content = $self->_substitute_port($content) if defined $content;
$resp->content($content);
print STDERR "HTTP::Response with content: \n", $resp->as_string if $log;
}
my $rhdr = $req->header ($hdrname);
my $ehdr = $url_rec->{'request_headers'}{$hdrname};
unless (defined $rhdr && $rhdr =~ $ehdr) {
+ $rhdr = '' unless defined $rhdr;
print STDERR "\n*** Mismatch on $hdrname: $rhdr =~ $ehdr\n";
return undef;
}
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $content = "You got it.\n";
+
+# code, msg, headers, content
+my %urls = (
+ '/one.txt' => {
+ code => "401",
+ msg => "Forbidden",
+ headers => {
+ "Set-Cookie" => "foo=bar",
+ },
+ },
+ '/two.txt' => {
+ code => "200",
+ msg => "Ok",
+ content => $content,
+ request_headers => {
+ "Cookie" => qr|foo=bar|,
+ },
+ },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -d http://localhost:{{port}}/one.txt"
+ . " http://localhost:{{port}}/two.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+ 'two.txt' => {
+ content => $content,
+ },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-cookies-401",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $page1 = "Hello, world!\n";
+my $page2 = "Goodbye, Sam.\n";
+
+# code, msg, headers, content
+my %urls = (
+ '/one.txt' => {
+ code => "200",
+ msg => "Ok",
+ headers => {
+ "Content-type" => "text/plain",
+ "Set-Cookie" => "foo=bar",
+ },
+ content => $page1,
+ },
+ '/two.txt' => {
+ code => "200",
+ msg => "Ok",
+ content => $page2,
+ request_headers => {
+ "Cookie" => qr|foo=bar|,
+ },
+ },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt"
+ . " http://localhost:{{port}}/two.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+ 'one.txt' => {
+ content => $page1,
+ },
+ 'two.txt' => {
+ content => $page2,
+ },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-cookies",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
'Test-auth-basic.px',
'Test-auth-no-challenge.px',
'Test-auth-no-challenge-url.px',
+ 'Test-cookies.px',
+ 'Test-cookies-401.px',
'Test-proxy-auth-basic.px',
'Test-proxied-https-auth.px',
'Test-N-HTTP-Content-Disposition.px',