2020-02-28 13:20:11 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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 HttpConnectionUDP_h__
|
|
|
|
#define HttpConnectionUDP_h__
|
|
|
|
|
|
|
|
#include "HttpConnectionBase.h"
|
|
|
|
#include "nsHttpConnectionInfo.h"
|
|
|
|
#include "nsHttpResponseHead.h"
|
|
|
|
#include "nsAHttpTransaction.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsProxyRelease.h"
|
|
|
|
#include "prinrval.h"
|
|
|
|
#include "TunnelUtils.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "ARefBase.h"
|
|
|
|
#include "TimingStruct.h"
|
|
|
|
#include "HttpTrafficAnalyzer.h"
|
|
|
|
|
|
|
|
#include "nsIAsyncInputStream.h"
|
|
|
|
#include "nsIAsyncOutputStream.h"
|
2021-08-11 19:07:54 +03:00
|
|
|
#include "nsISupportsPriority.h"
|
2020-02-28 13:20:11 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "Http3Session.h"
|
|
|
|
|
|
|
|
class nsISocketTransport;
|
|
|
|
class nsISSLSocketControl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
class nsHttpHandler;
|
|
|
|
class ASpdySession;
|
|
|
|
|
|
|
|
// 1dcc863e-db90-4652-a1fe-13fea0b54e46
|
|
|
|
#define HTTPCONNECTIONUDP_IID \
|
|
|
|
{ \
|
|
|
|
0xb97d2036, 0xb441, 0x48be, { \
|
|
|
|
0xb3, 0x1e, 0x25, 0x3e, 0xe8, 0x32, 0xdd, 0x67 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpConnectionUDP - represents a connection to a HTTP3 server
|
|
|
|
//
|
|
|
|
// NOTE: this objects lives on the socket thread only. it should not be
|
|
|
|
// accessed from any other thread.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class HttpConnectionUDP final : public HttpConnectionBase,
|
2021-02-26 11:42:49 +03:00
|
|
|
public nsIUDPSocketSyncListener,
|
2020-02-28 14:00:07 +03:00
|
|
|
public nsIInterfaceRequestor {
|
2020-02-28 13:20:11 +03:00
|
|
|
private:
|
|
|
|
virtual ~HttpConnectionUDP();
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(HTTPCONNECTIONUDP_IID)
|
|
|
|
NS_DECL_HTTPCONNECTIONBASE
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2021-02-26 11:42:49 +03:00
|
|
|
NS_DECL_NSIUDPSOCKETSYNCLISTENER
|
2020-02-28 13:20:11 +03:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
|
|
|
HttpConnectionUDP();
|
|
|
|
|
2021-02-26 11:42:49 +03:00
|
|
|
[[nodiscard]] nsresult Init(nsHttpConnectionInfo* info,
|
|
|
|
nsIDNSRecord* dnsRecord, nsresult status,
|
|
|
|
nsIInterfaceRequestor* callbacks, uint32_t caps);
|
|
|
|
|
2020-02-28 13:20:11 +03:00
|
|
|
friend class HttpConnectionUDPForceIO;
|
|
|
|
|
2020-04-18 09:37:32 +03:00
|
|
|
[[nodiscard]] static nsresult ReadFromStream(nsIInputStream*, void*,
|
|
|
|
const char*, uint32_t, uint32_t,
|
|
|
|
uint32_t*);
|
2020-02-28 13:20:11 +03:00
|
|
|
|
2020-02-28 14:00:07 +03:00
|
|
|
bool UsingHttp3() override { return true; }
|
2020-02-28 13:20:11 +03:00
|
|
|
|
2020-03-04 17:17:12 +03:00
|
|
|
static void OnQuicTimeout(nsITimer* aTimer, void* aClosure);
|
|
|
|
void OnQuicTimeoutExpired();
|
|
|
|
|
2021-02-26 11:42:49 +03:00
|
|
|
int64_t BytesWritten() override;
|
|
|
|
|
2021-02-26 11:42:49 +03:00
|
|
|
nsresult GetSelfAddr(NetAddr* addr) override;
|
|
|
|
nsresult GetPeerAddr(NetAddr* addr) override;
|
|
|
|
bool ResolvedByTRR() override;
|
|
|
|
bool GetEchConfigUsed() override { return false; }
|
|
|
|
|
2020-02-28 13:20:11 +03:00
|
|
|
private:
|
2020-04-18 09:37:32 +03:00
|
|
|
[[nodiscard]] nsresult OnTransactionDone(nsresult reason);
|
2021-02-26 11:42:49 +03:00
|
|
|
nsresult RecvData();
|
|
|
|
nsresult SendData();
|
2020-02-28 13:20:11 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<nsHttpHandler> mHttpHandler; // keep gHttpHandler alive
|
|
|
|
|
|
|
|
RefPtr<nsIAsyncInputStream> mInputOverflow;
|
|
|
|
|
2021-06-04 15:35:16 +03:00
|
|
|
bool mConnectedTransport = false;
|
|
|
|
bool mDontReuse = false;
|
|
|
|
bool mIsReused = false;
|
|
|
|
bool mLastTransactionExpectedNoContent = false;
|
2020-02-28 13:20:11 +03:00
|
|
|
|
2021-06-04 15:35:16 +03:00
|
|
|
int32_t mPriority = nsISupportsPriority::PRIORITY_NORMAL;
|
2020-02-28 13:20:11 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// For ForceSend()
|
|
|
|
static void ForceSendIO(nsITimer* aTimer, void* aClosure);
|
2020-04-18 09:37:32 +03:00
|
|
|
[[nodiscard]] nsresult MaybeForceSendIO();
|
2021-06-04 15:35:16 +03:00
|
|
|
bool mForceSendPending = false;
|
2020-02-28 13:20:11 +03:00
|
|
|
nsCOMPtr<nsITimer> mForceSendTimer;
|
|
|
|
|
2021-06-04 15:35:16 +03:00
|
|
|
PRIntervalTime mLastRequestBytesSentTime = 0;
|
2021-02-26 11:42:49 +03:00
|
|
|
nsCOMPtr<nsIUDPSocket> mSocket;
|
2020-02-28 13:20:11 +03:00
|
|
|
|
2021-02-26 11:42:49 +03:00
|
|
|
nsCOMPtr<nsINetAddr> mSelfAddr;
|
|
|
|
nsCOMPtr<nsINetAddr> mPeerAddr;
|
|
|
|
bool mResolvedByTRR = false;
|
2021-03-02 19:14:46 +03:00
|
|
|
|
2020-02-28 13:20:11 +03:00
|
|
|
private:
|
|
|
|
// Http3
|
|
|
|
RefPtr<Http3Session> mHttp3Session;
|
2021-03-10 11:02:55 +03:00
|
|
|
nsCString mAlpnToken;
|
2020-02-28 13:20:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(HttpConnectionUDP, HTTPCONNECTIONUDP_IID)
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // HttpConnectionUDP_h__
|