diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 02:33:58 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 02:33:58 +0000 |
commit | 7ec7c1899afc8537bb25ce373aa2e136aa7788dc (patch) | |
tree | c108e17742ec31aef01eef3824d1388b8a3f8937 /net/base/net_util_unittest.cc | |
parent | 5cd1f8f498abd2ed8d0bd545b224b95918cbec72 (diff) | |
download | chromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.zip chromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.tar.gz chromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.tar.bz2 |
Split out HttpUtil::SpecForRequest() into a more generic function of net_util.h.
This was a TODO, since that function is useful outside of HTTP.
In the process, I uncovered some test cases in proxy_service that are passing in invalid URLs (by virtue of the extra DCHECK). This doesn't make much sense to me to support that, so I have changed them.
Review URL: http://codereview.chromium.org/160558
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util_unittest.cc')
-rw-r--r-- | net/base/net_util_unittest.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index feb4be7..726529e 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -1269,3 +1269,47 @@ TEST(NetUtilTest, FormatUrlParsed) { EXPECT_EQ(L"query", formatted.substr(parsed.query.begin, parsed.query.len)); EXPECT_EQ(L"ref", formatted.substr(parsed.ref.begin, parsed.ref.len)); } + +TEST(NetUtilTest, SimplifyUrlForRequest) { + struct { + const char* input_url; + const char* expected_simplified_url; + } tests[] = { + { + // Reference section should be stripped. + "http://www.google.com:78/foobar?query=1#hash", + "http://www.google.com:78/foobar?query=1", + }, + { + // Reference section can itself contain #. + "http://192.168.0.1?query=1#hash#10#11#13#14", + "http://192.168.0.1?query=1", + }, + { // Strip username/password. + "http://user:pass@google.com", + "http://google.com/", + }, + { // Strip both the reference and the username/password. + "http://user:pass@google.com:80/sup?yo#X#X", + "http://google.com/sup?yo", + }, + { // Try an HTTPS URL -- strip both the reference and the username/password. + "https://user:pass@google.com:80/sup?yo#X#X", + "https://google.com:80/sup?yo", + }, + { // Try an FTP URL -- strip both the reference and the username/password. + "ftp://user:pass@google.com:80/sup?yo#X#X", + "ftp://google.com:80/sup?yo", + }, + { // Try an standard URL with unknow scheme. + "foobar://user:pass@google.com:80/sup?yo#X#X", + "foobar://google.com:80/sup?yo", + }, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].input_url)); + GURL input_url(GURL(tests[i].input_url)); + GURL expected_url(GURL(tests[i].expected_simplified_url)); + EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); + } +} |