| 47 | |
| 48 | |
| 49 | class TestUtil: |
| 50 | url_host_map = [ |
| 51 | # Hosts |
| 52 | ("http://google.com/mail", ("http", "google.com", None)), |
| 53 | ("http://google.com/mail/", ("http", "google.com", None)), |
| 54 | ("google.com/mail", ("http", "google.com", None)), |
| 55 | ("http://google.com/", ("http", "google.com", None)), |
| 56 | ("http://google.com", ("http", "google.com", None)), |
| 57 | ("http://www.google.com", ("http", "www.google.com", None)), |
| 58 | ("http://mail.google.com", ("http", "mail.google.com", None)), |
| 59 | ("http://google.com:8000/mail/", ("http", "google.com", 8000)), |
| 60 | ("http://google.com:8000", ("http", "google.com", 8000)), |
| 61 | ("https://google.com", ("https", "google.com", None)), |
| 62 | ("https://google.com:8000", ("https", "google.com", 8000)), |
| 63 | ("http://user:password@127.0.0.1:1234", ("http", "127.0.0.1", 1234)), |
| 64 | ("http://google.com/foo=http://bar:42/baz", ("http", "google.com", None)), |
| 65 | ("http://google.com?foo=http://bar:42/baz", ("http", "google.com", None)), |
| 66 | ("http://google.com#foo=http://bar:42/baz", ("http", "google.com", None)), |
| 67 | # IPv4 |
| 68 | ("173.194.35.7", ("http", "173.194.35.7", None)), |
| 69 | ("http://173.194.35.7", ("http", "173.194.35.7", None)), |
| 70 | ("http://173.194.35.7/test", ("http", "173.194.35.7", None)), |
| 71 | ("http://173.194.35.7:80", ("http", "173.194.35.7", 80)), |
| 72 | ("http://173.194.35.7:80/test", ("http", "173.194.35.7", 80)), |
| 73 | # IPv6 |
| 74 | ("[2a00:1450:4001:c01::67]", ("http", "[2a00:1450:4001:c01::67]", None)), |
| 75 | ("http://[2a00:1450:4001:c01::67]", ("http", "[2a00:1450:4001:c01::67]", None)), |
| 76 | ( |
| 77 | "http://[2a00:1450:4001:c01::67]/test", |
| 78 | ("http", "[2a00:1450:4001:c01::67]", None), |
| 79 | ), |
| 80 | ( |
| 81 | "http://[2a00:1450:4001:c01::67]:80", |
| 82 | ("http", "[2a00:1450:4001:c01::67]", 80), |
| 83 | ), |
| 84 | ( |
| 85 | "http://[2a00:1450:4001:c01::67]:80/test", |
| 86 | ("http", "[2a00:1450:4001:c01::67]", 80), |
| 87 | ), |
| 88 | # More IPv6 from http://www.ietf.org/rfc/rfc2732.txt |
| 89 | ( |
| 90 | "http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:8000/index.html", |
| 91 | ("http", "[fedc:ba98:7654:3210:fedc:ba98:7654:3210]", 8000), |
| 92 | ), |
| 93 | ( |
| 94 | "http://[1080:0:0:0:8:800:200c:417a]/index.html", |
| 95 | ("http", "[1080:0:0:0:8:800:200c:417a]", None), |
| 96 | ), |
| 97 | ("http://[3ffe:2a00:100:7031::1]", ("http", "[3ffe:2a00:100:7031::1]", None)), |
| 98 | ( |
| 99 | "http://[1080::8:800:200c:417a]/foo", |
| 100 | ("http", "[1080::8:800:200c:417a]", None), |
| 101 | ), |
| 102 | ("http://[::192.9.5.5]/ipng", ("http", "[::192.9.5.5]", None)), |
| 103 | ( |
| 104 | "http://[::ffff:129.144.52.38]:42/index.html", |
| 105 | ("http", "[::ffff:129.144.52.38]", 42), |
| 106 | ), |