Add default port method to request API
authorscantor <scantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 1 Feb 2012 20:45:59 +0000 (20:45 +0000)
committerscantor <scantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 1 Feb 2012 20:45:59 +0000 (20:45 +0000)
git-svn-id: https://svn.shibboleth.net/cpp-xmltooling/branches/REL_1@958 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/io/GenericRequest.h
xmltooling/io/HTTPRequest.cpp
xmltooling/io/HTTPRequest.h

index 11cd82b..7dcb165 100644 (file)
@@ -85,6 +85,13 @@ namespace xmltooling {
         virtual int getPort() const=0;
 
         /**
+         * Returns true iff the request port is the default port for the request protocol.
+         *
+         * @return  default port indicator
+         */
+        virtual bool isDefaultPort() const;
+
+        /**
          * Returns the MIME type of the request, if known.
          *
          * @return the MIME type, or an empty string
index a068a58..b038830 100644 (file)
@@ -51,6 +51,11 @@ GenericRequest::~GenericRequest()
 {
 }
 
+bool GenericRequest::isDefaultPort() const
+{
+    return false;
+}
+
 void GenericRequest::setLangDefaults(bool langFromClient, const XMLCh* defaultRange)
 {
     m_langFromClient = langFromClient;
@@ -184,6 +189,14 @@ bool HTTPRequest::isSecure() const
     return strcmp(getScheme(),"https")==0;
 }
 
+bool HTTPRequest::isDefaultPort() const
+{
+    if (isSecure())
+        return getPort() == 443;
+    else
+        return getPort() == 80;
+}
+
 string HTTPRequest::getLanguageRange() const
 {
     return getHeader("Accept-Language");
index 7cca6c1..e4b2d79 100644 (file)
@@ -55,6 +55,7 @@ namespace xmltooling {
         virtual ~HTTPRequest();
 
         bool isSecure() const;
+        bool isDefaultPort() const;
         std::string getLanguageRange() const;
           
         /**