LCOV - code coverage report
Current view: directory - netwerk/protocol/http - nsHttpConnectionInfo.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 34 32 94.1 %
Date: 2012-06-02 Functions: 3 3 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Darin Fisher <darin@netscape.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "nsHttpConnectionInfo.h"
      40                 : #include "nsIProtocolProxyService.h"
      41                 : 
      42                 : void
      43            3805 : nsHttpConnectionInfo::SetOriginServer(const nsACString &host, PRInt32 port)
      44                 : {
      45            3805 :     mHost = host;
      46            3805 :     mPort = port == -1 ? DefaultPort() : port;
      47                 : 
      48                 :     //
      49                 :     // build hash key:
      50                 :     //
      51                 :     // the hash key uniquely identifies the connection type.  two connections
      52                 :     // are "equal" if they end up talking the same protocol to the same server
      53                 :     // and are both used for anonymous or non-anonymous connection only;
      54                 :     // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen
      55                 :     // where we know we use anonymous connection (LOAD_ANONYMOUS load flag)
      56                 :     //
      57                 : 
      58                 :     const char *keyHost;
      59                 :     PRInt32 keyPort;
      60                 : 
      61            3805 :     if (mUsingHttpProxy && !mUsingSSL) {
      62              20 :         keyHost = ProxyHost();
      63              20 :         keyPort = ProxyPort();
      64                 :     }
      65                 :     else {
      66            3785 :         keyHost = Host();
      67            3785 :         keyPort = Port();
      68                 :     }
      69                 : 
      70            3805 :     mHashKey.AssignLiteral("...");
      71            3805 :     mHashKey.Append(keyHost);
      72            3805 :     mHashKey.Append(':');
      73            3805 :     mHashKey.AppendInt(keyPort);
      74                 : 
      75            3805 :     if (mUsingHttpProxy)
      76              20 :         mHashKey.SetCharAt('P', 0);
      77            3805 :     if (mUsingSSL)
      78               9 :         mHashKey.SetCharAt('S', 1);
      79                 : 
      80                 :     // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy
      81                 :     // type in the hash key (this ensures that we will continue to speak the
      82                 :     // right protocol even if our proxy preferences change).
      83            3805 :     if (!mUsingHttpProxy && ProxyHost()) {
      84              10 :         mHashKey.AppendLiteral(" (");
      85              10 :         mHashKey.Append(ProxyType());
      86              10 :         mHashKey.Append(')');
      87                 :     }
      88            3805 : }
      89                 : 
      90                 : nsHttpConnectionInfo*
      91             291 : nsHttpConnectionInfo::Clone() const
      92                 : {
      93             582 :     nsHttpConnectionInfo* clone = new nsHttpConnectionInfo(mHost, mPort, mProxyInfo, mUsingSSL);
      94             291 :     if (!clone)
      95               0 :         return nsnull;
      96                 : 
      97                 :     // Make sure the anonymous flag is transferred!
      98             291 :     clone->SetAnonymous(mHashKey.CharAt(2) == 'A');
      99                 :     
     100             291 :     return clone;
     101                 : }
     102                 : 
     103                 : bool
     104            8951 : nsHttpConnectionInfo::ShouldForceConnectMethod()
     105                 : {
     106            8951 :     if (!mProxyInfo)
     107            8870 :         return false;
     108                 :     
     109                 :     PRUint32 resolveFlags;
     110                 :     nsresult rv;
     111                 :     
     112              81 :     rv = mProxyInfo->GetResolveFlags(&resolveFlags);
     113              81 :     if (NS_FAILED(rv))
     114               0 :         return false;
     115                 : 
     116              81 :     return resolveFlags & nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL;
     117                 : }

Generated by: LCOV version 1.7