[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-157-
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-157-g6ce0bb4 |
Date: |
Fri, 16 Apr 2010 21:13:26 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".
The branch, master has been updated
via 6ce0bb4748c478112b86b5370dbe4f14f51fc10e (commit)
via 50e1dd95347eb8bb2c332e3c56762880573db4b6 (commit)
from 29f2439da0cd2a0d6d4fb4964451990753044d12 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6ce0bb4748c478112b86b5370dbe4f14f51fc10e
Merge: 29f2439 50e1dd9
Author: Giuseppe Scrivano <address@hidden>
Date: Fri Apr 16 23:12:35 2010 +0200
Merge branch 'master' of git://github.com/rupinder/GNU-MyServer
commit 50e1dd95347eb8bb2c332e3c56762880573db4b6
Author: Rupinder Singh <address@hidden>
Date: Sat Apr 17 01:56:26 2010 +0530
New function for returning number of fields in url class
diff --git a/myserver/include/protocol/url.h b/myserver/include/protocol/url.h
index 47934aa..e10d5bb 100644
--- a/myserver/include/protocol/url.h
+++ b/myserver/include/protocol/url.h
@@ -31,6 +31,7 @@ public:
Url (const char*, u_short port);
string& getProtocol ();
u_short getPort ();
+ int getNumFields ();
string& getResource ();
string& getHost ();
string& getQuery ();
diff --git a/myserver/src/protocol/url.cpp b/myserver/src/protocol/url.cpp
index 2f018eb..e58940d 100644
--- a/myserver/src/protocol/url.cpp
+++ b/myserver/src/protocol/url.cpp
@@ -48,7 +48,6 @@ string& Url::getProtocol ()
return protocol;
}
-
/*!
*Get the query part of the URL.
*/
@@ -58,6 +57,20 @@ string& Url::getQuery ()
}
/*!
+ *Get the number of fields in the query
+ */
+int Url::getNumFields ()
+{
+ int l = query.length ();
+ int numFields = (l != 0);
+
+ for (int i = 0; i < l; i++)
+ numFields += (query[i] == '&');
+
+ return numFields;
+}
+
+/*!
*Get the credentials part of the URL.
*/
string& Url::getCredentials ()
diff --git a/myserver/tests/test_url.cpp b/myserver/tests/test_url.cpp
index 9b773fb..944be1b 100644
--- a/myserver/tests/test_url.cpp
+++ b/myserver/tests/test_url.cpp
@@ -60,20 +60,21 @@ public:
CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
CPPUNIT_ASSERT (!url.getQuery ().compare (""));
- CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+ CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short) 8080);
}
void testUrlWithQuery ()
{
- const char *urlStr = "http://foo.bar:8080/what/i/want?my_query";
+ const char *urlStr = "http://foo.bar:8080/what/i/want?my_query1&my_query2";
Url url (urlStr, 80);
CPPUNIT_ASSERT (!url.getCredentials ().compare (""));
CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
- CPPUNIT_ASSERT (!url.getQuery ().compare ("my_query"));
- CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+ CPPUNIT_ASSERT (!url.getQuery ().compare ("my_query1&my_query2"));
+ CPPUNIT_ASSERT_EQUAL (url.getNumFields (), 2);
+ CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short) 8080);
}
void testUrl ()
@@ -86,7 +87,7 @@ public:
CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
CPPUNIT_ASSERT (!url.getQuery ().compare (""));
- CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+ CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short) 8080);
}
void testUrlWithoutPort ()
@@ -98,7 +99,7 @@ public:
CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
- CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)80);
+ CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short) 80);
}
};
-----------------------------------------------------------------------
Summary of changes:
myserver/include/protocol/url.h | 1 +
myserver/src/protocol/url.cpp | 15 ++++++++++++++-
myserver/tests/test_url.cpp | 13 +++++++------
3 files changed, 22 insertions(+), 7 deletions(-)
hooks/post-receive
--
GNU MyServer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-157-g6ce0bb4,
Giuseppe Scrivano <=