summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-11-13 10:15:29 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-11-13 10:50:15 (GMT)
commit59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b (patch)
tree8b911fee527973ec3406640b0dfa8c7dcd6cf8b6 /Swiften/Base
parentd26ad781dd4d1fa2019d31d5effabb9d662a8417 (diff)
downloadswift-59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b.zip
swift-59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b.tar.bz2
Allow BOSH URL setting again.
Also fixes use of getPort() so that HTTP headers aren't all for port :1. Change-Id: I8ead8a7f4826d1105bf1feafea21e6139e803de7 Resolves: #1178
Diffstat (limited to 'Swiften/Base')
-rw-r--r--Swiften/Base/URL.cpp2
-rw-r--r--Swiften/Base/UnitTest/URLTest.cpp20
2 files changed, 16 insertions, 6 deletions
diff --git a/Swiften/Base/URL.cpp b/Swiften/Base/URL.cpp
index 320e2ad..866cd45 100644
--- a/Swiften/Base/URL.cpp
+++ b/Swiften/Base/URL.cpp
@@ -45,7 +45,7 @@ URL URL::fromString(const std::string& urlString) {
}
else {
authority = urlString.substr(authorityIndex, slashIndex - authorityIndex);
- path = unescape(urlString.substr(slashIndex + 1));
+ path = unescape(urlString.substr(slashIndex));
}
size_t atIndex = authority.find('@');
diff --git a/Swiften/Base/UnitTest/URLTest.cpp b/Swiften/Base/UnitTest/URLTest.cpp
index 09912ed..e82321f 100644
--- a/Swiften/Base/UnitTest/URLTest.cpp
+++ b/Swiften/Base/UnitTest/URLTest.cpp
@@ -18,6 +18,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testFromString_WithoutPath);
CPPUNIT_TEST(testFromString_WithRootPath);
CPPUNIT_TEST(testFromString_WithPort);
+ CPPUNIT_TEST(testFromString_WithPortOnePartPath);
CPPUNIT_TEST(testFromString_WithPortWithoutPath);
CPPUNIT_TEST(testFromString_WithUserInfo);
CPPUNIT_TEST(testFromString_NonASCIIHost);
@@ -33,7 +34,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
CPPUNIT_ASSERT(!url.getPort());
- CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath());
}
void testFromString_WithoutPath() {
@@ -51,7 +52,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
CPPUNIT_ASSERT(!url.getPort());
- CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("/"), url.getPath());
}
void testFromString_WithPort() {
@@ -60,7 +61,16 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
CPPUNIT_ASSERT_EQUAL(1234, *url.getPort());
- CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath());
+ }
+
+ void testFromString_WithPortOnePartPath() {
+ URL url = URL::fromString("http://foo.bar:11440/http-bind/");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
+ CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
+ CPPUNIT_ASSERT_EQUAL(11440, *url.getPort());
+ CPPUNIT_ASSERT_EQUAL(std::string("/http-bind/"), url.getPath());
}
void testFromString_WithPortWithoutPath() {
@@ -77,7 +87,7 @@ class URLTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme());
CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost());
- CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath());
}
void testFromString_NonASCIIHost() {
@@ -89,7 +99,7 @@ class URLTest : public CppUnit::TestFixture {
void testFromString_NonASCIIPath() {
URL url = URL::fromString("http://foo.bar/baz/tron%C3%A7on/bam");
- CPPUNIT_ASSERT_EQUAL(std::string("baz/tron\xc3\xa7on/bam"), url.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("/baz/tron\xc3\xa7on/bam"), url.getPath());
}
void testToString() {