Bug 458256. Use LoadLibraryW instead of LoadLibrary (patch by DougT). r+sr=vlad
[wine-gecko.git] / netwerk / protocol / http / src / nsHttpConnectionInfo.h
blobf0c6e72395b43d455044dbdc9177fdaa768a35ff
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
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/
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.
15 * The Original Code is Mozilla.
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.
22 * Contributor(s):
23 * Darin Fisher <darin@netscape.com> (original author)
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.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsHttpConnectionInfo_h__
40 #define nsHttpConnectionInfo_h__
42 #include "nsHttp.h"
43 #include "nsProxyInfo.h"
44 #include "nsCOMPtr.h"
45 #include "nsDependentString.h"
46 #include "nsString.h"
47 #include "plstr.h"
48 #include "nsCRT.h"
50 //-----------------------------------------------------------------------------
51 // nsHttpConnectionInfo - holds the properties of a connection
52 //-----------------------------------------------------------------------------
54 class nsHttpConnectionInfo
56 public:
57 nsHttpConnectionInfo(const nsACString &host, PRInt32 port,
58 nsProxyInfo* proxyInfo,
59 PRBool usingSSL=PR_FALSE)
60 : mRef(0)
61 , mProxyInfo(proxyInfo)
62 , mUsingSSL(usingSSL)
64 LOG(("Creating nsHttpConnectionInfo @%x\n", this));
66 mUsingHttpProxy = (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http"));
68 SetOriginServer(host, port);
71 ~nsHttpConnectionInfo()
73 LOG(("Destroying nsHttpConnectionInfo @%x\n", this));
76 nsrefcnt AddRef()
78 nsrefcnt n = PR_AtomicIncrement((PRInt32 *) &mRef);
79 NS_LOG_ADDREF(this, n, "nsHttpConnectionInfo", sizeof(*this));
80 return n;
83 nsrefcnt Release()
85 nsrefcnt n = PR_AtomicDecrement((PRInt32 *) &mRef);
86 NS_LOG_RELEASE(this, n, "nsHttpConnectionInfo");
87 if (n == 0)
88 delete this;
89 return n;
92 const nsAFlatCString &HashKey() const { return mHashKey; }
94 void SetOriginServer(const nsACString &host, PRInt32 port);
96 void SetOriginServer(const char *host, PRInt32 port)
98 SetOriginServer(nsDependentCString(host), port);
101 const char *ProxyHost() const { return mProxyInfo ? mProxyInfo->Host().get() : nsnull; }
102 PRInt32 ProxyPort() const { return mProxyInfo ? mProxyInfo->Port() : -1; }
103 const char *ProxyType() const { return mProxyInfo ? mProxyInfo->Type() : nsnull; }
105 // Compare this connection info to another...
106 // Two connections are 'equal' if they end up talking the same
107 // protocol to the same server. This is needed to properly manage
108 // persistent connections to proxies
109 // Note that we don't care about transparent proxies -
110 // it doesn't matter if we're talking via socks or not, since
111 // a request will end up at the same host.
112 PRBool Equals(const nsHttpConnectionInfo *info)
114 return mHashKey.Equals(info->HashKey());
117 const char *Host() const { return mHost.get(); }
118 PRInt32 Port() const { return mPort; }
119 nsProxyInfo *ProxyInfo() { return mProxyInfo; }
120 PRBool UsingHttpProxy() const { return mUsingHttpProxy; }
121 PRBool UsingSSL() const { return mUsingSSL; }
122 PRInt32 DefaultPort() const { return mUsingSSL ? NS_HTTPS_DEFAULT_PORT : NS_HTTP_DEFAULT_PORT; }
124 private:
125 nsrefcnt mRef;
126 nsCString mHashKey;
127 nsCString mHost;
128 PRInt32 mPort;
129 nsCOMPtr<nsProxyInfo> mProxyInfo;
130 PRPackedBool mUsingHttpProxy;
131 PRPackedBool mUsingSSL;
134 #endif // nsHttpConnectionInfo_h__