mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8c296bbcd4
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
125 lines
4.5 KiB
C++
125 lines
4.5 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef nsHttpConnectionInfo_h__
|
|
#define nsHttpConnectionInfo_h__
|
|
|
|
#include "nsHttp.h"
|
|
#include "nsProxyInfo.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsDependentString.h"
|
|
#include "nsString.h"
|
|
#include "plstr.h"
|
|
#include "nsCRT.h"
|
|
#include "nsIProtocolProxyService.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// nsHttpConnectionInfo - holds the properties of a connection
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class nsHttpConnectionInfo
|
|
{
|
|
public:
|
|
nsHttpConnectionInfo(const nsACString &host, int32_t port,
|
|
nsProxyInfo* proxyInfo,
|
|
bool usingSSL=false)
|
|
: mRef(0)
|
|
, mProxyInfo(proxyInfo)
|
|
, mUsingSSL(usingSSL)
|
|
, mUsingConnect(false)
|
|
{
|
|
LOG(("Creating nsHttpConnectionInfo @%x\n", this));
|
|
|
|
mUsingHttpProxy = (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http"));
|
|
|
|
if (mUsingHttpProxy) {
|
|
mUsingConnect = mUsingSSL; // SSL always uses CONNECT
|
|
uint32_t resolveFlags = 0;
|
|
if (NS_SUCCEEDED(mProxyInfo->GetResolveFlags(&resolveFlags)) &&
|
|
resolveFlags & nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL) {
|
|
mUsingConnect = true;
|
|
}
|
|
}
|
|
|
|
SetOriginServer(host, port);
|
|
}
|
|
|
|
~nsHttpConnectionInfo()
|
|
{
|
|
LOG(("Destroying nsHttpConnectionInfo @%x\n", this));
|
|
}
|
|
|
|
nsrefcnt AddRef()
|
|
{
|
|
nsrefcnt n = NS_AtomicIncrementRefcnt(mRef);
|
|
NS_LOG_ADDREF(this, n, "nsHttpConnectionInfo", sizeof(*this));
|
|
return n;
|
|
}
|
|
|
|
nsrefcnt Release()
|
|
{
|
|
nsrefcnt n = NS_AtomicDecrementRefcnt(mRef);
|
|
NS_LOG_RELEASE(this, n, "nsHttpConnectionInfo");
|
|
if (n == 0)
|
|
delete this;
|
|
return n;
|
|
}
|
|
|
|
const nsAFlatCString &HashKey() const { return mHashKey; }
|
|
|
|
void SetOriginServer(const nsACString &host, int32_t port);
|
|
|
|
void SetOriginServer(const char *host, int32_t port)
|
|
{
|
|
SetOriginServer(nsDependentCString(host), port);
|
|
}
|
|
|
|
// OK to treat this as an infalible allocation
|
|
nsHttpConnectionInfo* Clone() const;
|
|
|
|
const char *ProxyHost() const { return mProxyInfo ? mProxyInfo->Host().get() : nullptr; }
|
|
int32_t ProxyPort() const { return mProxyInfo ? mProxyInfo->Port() : -1; }
|
|
const char *ProxyType() const { return mProxyInfo ? mProxyInfo->Type() : nullptr; }
|
|
|
|
// Compare this connection info to another...
|
|
// Two connections are 'equal' if they end up talking the same
|
|
// protocol to the same server. This is needed to properly manage
|
|
// persistent connections to proxies
|
|
// Note that we don't care about transparent proxies -
|
|
// it doesn't matter if we're talking via socks or not, since
|
|
// a request will end up at the same host.
|
|
bool Equals(const nsHttpConnectionInfo *info)
|
|
{
|
|
return mHashKey.Equals(info->HashKey());
|
|
}
|
|
|
|
const char *Host() const { return mHost.get(); }
|
|
int32_t Port() const { return mPort; }
|
|
nsProxyInfo *ProxyInfo() { return mProxyInfo; }
|
|
bool UsingHttpProxy() const { return mUsingHttpProxy; }
|
|
bool UsingSSL() const { return mUsingSSL; }
|
|
bool UsingConnect() const { return mUsingConnect; }
|
|
int32_t DefaultPort() const { return mUsingSSL ? NS_HTTPS_DEFAULT_PORT : NS_HTTP_DEFAULT_PORT; }
|
|
void SetAnonymous(bool anon)
|
|
{ mHashKey.SetCharAt(anon ? 'A' : '.', 2); }
|
|
bool GetAnonymous() const { return mHashKey.CharAt(2) == 'A'; }
|
|
void SetPrivate(bool priv) { mHashKey.SetCharAt(priv ? 'P' : '.', 3); }
|
|
bool GetPrivate() const { return mHashKey.CharAt(3) == 'P'; }
|
|
|
|
const nsCString &GetHost() { return mHost; }
|
|
|
|
private:
|
|
nsrefcnt mRef;
|
|
nsCString mHashKey;
|
|
nsCString mHost;
|
|
int32_t mPort;
|
|
nsCOMPtr<nsProxyInfo> mProxyInfo;
|
|
bool mUsingHttpProxy;
|
|
bool mUsingSSL;
|
|
bool mUsingConnect; // if will use CONNECT with http proxy
|
|
};
|
|
|
|
#endif // nsHttpConnectionInfo_h__
|