# 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/.

with Files("**"):
    BUG_COMPONENT = ("Core", "Networking: HTTP")

XPIDL_SOURCES += [
    "nsIBackgroundChannelRegistrar.idl",
    "nsIBinaryHttp.idl",
    "nsICORSPreflightCache.idl",
    "nsICORSPreflightCacheEntry.idl",
    "nsIEarlyHintObserver.idl",
    "nsIHttpActivityObserver.idl",
    "nsIHttpAuthCache.idl",
    "nsIHttpAuthenticableChannel.idl",
    "nsIHttpAuthenticator.idl",
    "nsIHttpAuthEntry.idl",
    "nsIHttpAuthManager.idl",
    "nsIHttpChannel.idl",
    "nsIHttpChannelAuthProvider.idl",
    "nsIHttpChannelChild.idl",
    "nsIHttpChannelInternal.idl",
    "nsIHttpHeaderVisitor.idl",
    "nsIHttpProtocolHandler.idl",
    "nsINetworkErrorLogging.idl",
    "nsIObliviousHttp.idl",
    "nsIObliviousHttpChannel.idl",
    "nsIReplacedHttpResponse.idl",
    "nsITlsHandshakeListener.idl",
    "nsIWellKnownOpportunisticUtils.idl",
]

XPIDL_MODULE = "necko_http"

EXPORTS += [
    "nsCORSListenerProxy.h",
    "nsHttp.h",
    "nsHttpAtomList.inc",
    "nsHttpHeaderArray.h",
    "nsHttpRequestHead.h",
    "nsHttpResponseHead.h",
]

EXPORTS.mozilla.net += [
    "AltDataOutputStreamChild.h",
    "AltDataOutputStreamParent.h",
    "AltServiceChild.h",
    "AltServiceParent.h",
    "AltSvcTransactionChild.h",
    "AltSvcTransactionParent.h",
    "BackgroundChannelRegistrar.h",
    "BackgroundDataBridgeChild.h",
    "BackgroundDataBridgeParent.h",
    "CacheControlParser.h",
    "CacheEntryWriteHandleChild.h",
    "CacheEntryWriteHandleParent.h",
    "ClassOfService.h",
    "EarlyHintPreloader.h",
    "EarlyHintRegistrar.h",
    "EarlyHintsService.h",
    "HttpAuthUtils.h",
    "HttpBackgroundChannelChild.h",
    "HttpBackgroundChannelParent.h",
    "HttpBaseChannel.h",
    "HttpChannelChild.h",
    "HttpChannelParent.h",
    "HttpConnectionMgrChild.h",
    "HttpConnectionMgrParent.h",
    "HttpConnectionMgrShell.h",
    "HttpInfo.h",
    "HttpTrafficAnalyzer.h",
    "HttpTransactionChild.h",
    "HttpTransactionParent.h",
    "HttpTransactionShell.h",
    "nsAHttpTransaction.h",
    "nsServerTiming.h",
    "NullHttpChannel.h",
    "NullHttpTransaction.h",
    "OpaqueResponseUtils.h",
    "ParentChannelListener.h",
    "PHttpChannelParams.h",
    "ReplacedHttpResponse.h",
    "SpeculativeTransaction.h",
    "TimingStruct.h",
]

SOURCES += [
    "nsHttpChannelAuthProvider.cpp",  # redefines GetAuthType
]

UNIFIED_SOURCES += [
    "AltDataOutputStreamChild.cpp",
    "AltDataOutputStreamParent.cpp",
    "AlternateServices.cpp",
    "AltServiceChild.cpp",
    "AltServiceParent.cpp",
    "AltSvcTransactionChild.cpp",
    "AltSvcTransactionParent.cpp",
    "ASpdySession.cpp",
    "BackgroundChannelRegistrar.cpp",
    "BackgroundDataBridgeChild.cpp",
    "BackgroundDataBridgeParent.cpp",
    "BinaryHttpRequest.cpp",
    "CacheControlParser.cpp",
    "Capsule.cpp",
    "CapsuleDecoder.cpp",
    "CapsuleEncoder.cpp",
    "CapsuleParser.cpp",
    "ConnectionAttempt.cpp",
    "ConnectionAttemptPool.cpp",
    "ConnectionDiagnostics.cpp",
    "ConnectionEntry.cpp",
    "ConnectionEstablisher.cpp",
    "ConnectionHandle.cpp",
    "DnsAndConnectSocket.cpp",
    "EarlyHintPreconnect.cpp",
    "EarlyHintPreloader.cpp",
    "EarlyHintRegistrar.cpp",
    "EarlyHintsService.cpp",
    "HappyEyeballsConnectionAttempt.cpp",
    "HappyEyeballsTransaction.cpp",
    "Http2Compression.cpp",
    "Http2Session.cpp",
    "Http2Stream.cpp",
    "Http2StreamBase.cpp",
    "Http2StreamTunnel.cpp",
    "Http2WebTransportSession.cpp",
    "Http2WebTransportStream.cpp",
    "Http3ConnectUDPStream.cpp",
    "Http3Session.cpp",
    "Http3Stream.cpp",
    "Http3StreamTunnel.cpp",
    "Http3WebTransportSession.cpp",
    "Http3WebTransportStream.cpp",
    "HttpAuthUtils.cpp",
    "HttpBackgroundChannelChild.cpp",
    "HttpBackgroundChannelParent.cpp",
    "HttpBaseChannel.cpp",
    "HttpChannelChild.cpp",
    "HttpChannelParent.cpp",
    "HttpConnectionBase.cpp",
    "HttpConnectionMgrChild.cpp",
    "HttpConnectionMgrParent.cpp",
    "HttpConnectionUDP.cpp",
    "HttpInfo.cpp",
    "HTTPSRecordResolver.cpp",
    "HttpTrafficAnalyzer.cpp",
    "HttpTransactionChild.cpp",
    "HttpTransactionParent.cpp",
    "InterceptedHttpChannel.cpp",
    "MockHttpAuth.cpp",
    "NetworkMarker.cpp",
    "nsAHttpConnection.cpp",
    "nsCORSListenerProxy.cpp",
    "nsHttp.cpp",
    "nsHttpActivityDistributor.cpp",
    "nsHttpAuthCache.cpp",
    "nsHttpAuthManager.cpp",
    "nsHttpBasicAuth.cpp",
    "nsHttpChannel.cpp",
    "nsHttpChunkedDecoder.cpp",
    "nsHttpConnection.cpp",
    "nsHttpConnectionInfo.cpp",
    "nsHttpConnectionMgr.cpp",
    "nsHttpDigestAuth.cpp",
    "nsHttpHeaderArray.cpp",
    "nsHttpNTLMAuth.cpp",
    "nsHttpRequestHead.cpp",
    "nsHttpResponseHead.cpp",
    "nsHttpTransaction.cpp",
    "nsServerTiming.cpp",
    "NullHttpChannel.cpp",
    "NullHttpTransaction.cpp",
    "ObliviousHttpChannel.cpp",
    "ObliviousHttpService.cpp",
    "OpaqueResponseUtils.cpp",
    "ParentChannelListener.cpp",
    "PendingTransactionInfo.cpp",
    "PendingTransactionQueue.cpp",
    "QuicSocketControl.cpp",
    "ReplacedHttpResponse.cpp",
    "SpeculativeTransaction.cpp",
    "TlsHandshaker.cpp",
    "TLSTransportLayer.cpp",
    "TRRServiceChannel.cpp",
    "WebTransportCertificateVerifier.cpp",
    "WebTransportFlowControl.cpp",
    "WebTransportSessionBase.cpp",
    "WebTransportStreamBase.cpp",
    "ZeroRttHandle.cpp",
]

if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
    UNIFIED_SOURCES += [
        "HttpWinUtils.cpp",
    ]

if CONFIG["TARGET_OS"] == "OSX":
    UNIFIED_SOURCES += [
        "MicrosoftEntraSSOUtils.mm",
    ]
    OS_LIBS += [
        "-framework AuthenticationServices",
    ]

# These files cannot be built in unified mode because of OS X headers.
SOURCES += [
    "nsHttpHandler.cpp",
]

IPDL_SOURCES += [
    "HttpChannelParams.ipdlh",
    "PAltDataOutputStream.ipdl",
    "PAltService.ipdl",
    "PAltSvcTransaction.ipdl",
    "PBackgroundDataBridge.ipdl",
    "PCacheEntryWriteHandle.ipdl",
    "PHttpBackgroundChannel.ipdl",
    "PHttpChannel.ipdl",
    "PHttpConnectionMgr.ipdl",
    "PHttpTransaction.ipdl",
]

include("/ipc/chromium/chromium-config.mozbuild")

FINAL_LIBRARY = "xul"

LOCAL_INCLUDES += [
    "/dom/base",
    "/netwerk/base",
    "/netwerk/cookie",
    "/netwerk/dns",
    "/netwerk/ipc",
    "/netwerk/socket/neqo_glue",
    "/netwerk/url-classifier",
]

DEFINES["MOZ_APP_UA_NAME"] = f'"{CONFIG["MOZ_APP_UA_NAME"]}"'

if CONFIG["MOZ_AUTH_EXTENSION"]:
    LOCAL_INCLUDES += [
        "/extensions/auth",
    ]

EXTRA_JS_MODULES += [
    "HPKEConfigManager.sys.mjs",
    "NetworkErrorLogging.sys.mjs",
    "ObliviousHTTP.sys.mjs",
    "WellKnownOpportunisticUtils.sys.mjs",
]

DIRS += ["happy_eyeballs_glue"]

XPCOM_MANIFESTS += [
    "components.conf",
]

include("/tools/fuzzing/libfuzzer-config.mozbuild")
