Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e5f0561
[App] Add cross-platform streaming native HTTP transport (firebase_ht…
AustinBenoit Nov 26, 2026
6556348
[App][HTTP] Harden shared validation, error classes, Cookie strip, an…
AustinBenoit Nov 27, 2026
2c1cea3
[App][HTTP] Fix curl HEAD-on-303, check setopt/slist/multi calls, and…
AustinBenoit Nov 27, 2026
73094b4
[App][HTTP] Fix Apple early stream close, memory backpressure, proxy,…
AustinBenoit Nov 27, 2026
8f6b46b
[App][HTTP] Fix Android GET/HEAD body, early 4xx, HEAD-on-303, proxy,…
AustinBenoit Nov 27, 2026
9cc6737
[App][HTTP] Strengthen HTTP transport tests with socket-close, blocki…
AustinBenoit Nov 27, 2026
831910b
[App][HTTP] Return redirects to the caller, narrow error classes, and…
AustinBenoit Nov 30, 2026
5b3c416
[App][HTTP] Apple: stop following redirects, narrow error classes, fi…
AustinBenoit Nov 30, 2026
27d3823
[App][HTTP] Add a WebSocket client to the native transport (shared co…
AustinBenoit Nov 30, 2026
92ed1cb
[App][HTTP] Apple: WebSocket backend on NSURLSessionWebSocketTask
AustinBenoit Nov 30, 2026
0d279b1
[App][HTTP] Use libcurl with a bundled BoringSSL for the Android tran…
AustinBenoit Nov 30, 2026
346b171
[App][HTTP] Android: parse the system roots once into a shared X509_S…
AustinBenoit Nov 30, 2026
e1adac5
[App][HTTP] Make the Android transport opt-in (FIREBASE_ANDROID_HTTP_…
AustinBenoit Nov 30, 2026
3c00d4e
[App][HTTP] Audit fixes: reject URL userinfo on Apple, avoid RFC-forb…
AustinBenoit Nov 30, 2026
54e3cf6
[App][HTTP] Flush stranded libcurl upload sendbuf bytes while paused
AustinBenoit Dec 1, 2026
076530b
[App][HTTP] Classify iOS certificate errors wrapped in NSURLErrorSecu…
AustinBenoit Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 57 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ option(FIREBASE_USE_BORINGSSL
"Build against BoringSSL instead of using your system's OpenSSL." OFF)
option(FIREBASE_USE_LINUX_CXX11_ABI
"Build Linux SDK using the C++11 ABI instead of the legacy ABI." OFF)
option(FIREBASE_ANDROID_HTTP_CURL
"Build the native HTTP transport (app/http) for Android. Downloads and builds libcurl and BoringSSL."
OFF)

# This should only be enabled by the GitHub Action build script.
option(FIREBASE_GITHUB_ACTION_BUILD
Expand Down Expand Up @@ -426,8 +429,50 @@ if((FIREBASE_INCLUDE_DATABASE AND DESKTOP) AND NOT FIREBASE_INCLUDE_FIRESTORE)
add_external_library(leveldb)
endif()

# Some of the external libraries are not used for mobile.
if(DESKTOP)
# The Android native HTTP transport (app/http, built only with
# FIREBASE_ANDROID_HTTP_CURL) uses libcurl with a BoringSSL of its own, both
# linked statically. They are built with firebase_app, so there is nothing to
# do when reusing a prior Gradle build of it.
if(ANDROID AND FIREBASE_ANDROID_HTTP_CURL AND
NOT FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
set(firebase_build_android_curl ON)
message(STATUS "Building BoringSSL for the Android HTTP transport...")
build_android_boringssl()
message(STATUS "Build of BoringSSL for the Android HTTP transport complete.")

# Make libcurl's find_package(OpenSSL) resolve to that BoringSSL.
set(OPENSSL_INCLUDE_DIR ${BORINGSSL_ANDROID_SOURCE_DIR}/include
CACHE PATH "" FORCE)
set(OPENSSL_SSL_LIBRARY ${BORINGSSL_ANDROID_BINARY_DIR}/libssl.a
CACHE FILEPATH "" FORCE)
set(OPENSSL_CRYPTO_LIBRARY ${BORINGSSL_ANDROID_BINARY_DIR}/libcrypto.a
CACHE FILEPATH "" FORCE)
add_library(OpenSSL::Crypto STATIC IMPORTED GLOBAL)
set_target_properties(OpenSSL::Crypto PROPERTIES
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}"
)
add_library(OpenSSL::SSL STATIC IMPORTED GLOBAL)
set_target_properties(OpenSSL::SSL PROPERTIES
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto
)

# libcurl detects SSL_set0_wbio() by linking a C program against libssl.
# BoringSSL's libssl is C++, so that check fails for want of a C++ runtime
# rather than of the function. libcurl would add one to the check, and to
# everything linking libcurl, if OPENSSL_USE_STATIC_LIBS were set, but which
# C++ runtime to link is the final Android library's choice (ANDROID_STL).
# BoringSSL has the function, so state the result instead.
set(HAVE_SSL_SET0_WBIO 1)
else()
set(firebase_build_android_curl OFF)
endif()

# libcurl is used on desktop and by the Android HTTP transport, with the same
# configuration. The other external libraries here are not used for mobile.
if(DESKTOP OR firebase_build_android_curl)
# Configure libcurl before adding its subdirectory.
# Note: curl 8.23.0 requires CMake >= 3.18 (CMP0077=NEW), so plain set() of
# normal variables overrides curl's option() defaults without polluting the
Expand Down Expand Up @@ -532,12 +577,21 @@ if(DESKTOP)
endif()
endif()

if(ANDROID)
# Compile libcurl's public API with hidden visibility as well (its internal
# symbols already are), so the shared library the transport is linked into
# does not export it.
target_compile_definitions(libcurl_static PRIVATE CURL_STATICLIB)
endif()

# Clean up generic normal variables set specifically for curl so they do not
# leak into subsequent add_subdirectory() calls (zlib, firestore, etc.).
unset(BUILD_STATIC_LIBS)
unset(BUILD_EXAMPLES)

add_external_library(zlib)
if(DESKTOP)
add_external_library(zlib)
endif()
endif()

if(DESKTOP AND NOT CMAKE_CROSSCOMPILING)
Expand Down
7 changes: 7 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ if (NOT ANDROID AND NOT IOS)
add_subdirectory(rest)
endif()

# Cross-platform native streaming HTTP transport (libcurl on desktop and
# Android, NSURLSession on iOS/tvOS). On Android it brings in libcurl and
# BoringSSL, so it is only built on request.
if(NOT ANDROID OR FIREBASE_ANDROID_HTTP_CURL)
add_subdirectory(http)
endif()

if(FIREBASE_CPP_BUILD_TESTS)
# Add the tests subdirectory
add_subdirectory(tests)
Expand Down
123 changes: 123 additions & 0 deletions app/http/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# CMake file for the cross-platform native streaming HTTP transport library
# (`firebase_http_transport`).

cmake_minimum_required(VERSION 3.22)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

set(http_transport_SRCS
http_bridge.h
http_transport.h
http_transport_common.cc
websocket.h
websocket_common.cc)

if(ANDROID)
# firebase_rest_lib is not built for Android, so the two libcurl helpers the
# curl backend shares with it are compiled into this library directly.
list(APPEND http_transport_SRCS
http_transport_curl.cc
http_transport_curl_internal.h
http_transport_curl_android.cc
http_transport_curl_platform.h
websocket_curl.cc
${FIREBASE_CPP_SDK_ROOT_DIR}/app/rest/curl/curl_handles.cc
${FIREBASE_CPP_SDK_ROOT_DIR}/app/rest/curl/tls_policy.cc)
elseif(IOS)
list(APPEND http_transport_SRCS
http_transport_apple.mm
websocket_apple.mm)
else()
list(APPEND http_transport_SRCS
http_transport_curl.cc
http_transport_curl_internal.h
websocket_curl.cc)
endif()

add_library(firebase_http_transport STATIC
${http_transport_SRCS})

set_property(TARGET firebase_http_transport PROPERTY FOLDER "Firebase Cpp")

# Match firebase_app's -fno-exceptions / /EHs-c- build settings.
if(MSVC)
target_compile_options(firebase_http_transport PRIVATE /EHs-c-)
else()
target_compile_options(firebase_http_transport PRIVATE -fno-exceptions)
endif()

target_include_directories(firebase_http_transport
PUBLIC
${FIREBASE_CPP_SDK_ROOT_DIR}
)

target_link_libraries(firebase_http_transport
PUBLIC
firebase_app
)

if(ANDROID)
# libcurl and the BoringSSL it was built against (see the top-level
# CMakeLists.txt) are linked statically into whatever links this library.
target_include_directories(firebase_http_transport
PRIVATE
${CURL_SOURCE_DIR}/include
)
target_compile_definitions(firebase_http_transport
PRIVATE
FIREBASE_HTTP_BUNDLED_BORINGSSL=1
)
target_link_libraries(firebase_http_transport
PRIVATE
libcurl
OpenSSL::SSL
OpenSSL::Crypto
)
elseif(IOS)
set_source_files_properties(http_transport_apple.mm websocket_apple.mm
PROPERTIES COMPILE_OPTIONS "-fobjc-arc"
)
target_link_libraries(firebase_http_transport
PRIVATE
"-framework Foundation"
)
else()
target_include_directories(firebase_http_transport
PRIVATE
${CURL_SOURCE_DIR}/include
)
if(MSVC)
target_compile_definitions(firebase_http_transport
PRIVATE
WIN32_LEAN_AND_MEAN
NOMINMAX
CURL_STATICLIB=1
)
endif()
target_link_libraries(firebase_http_transport
PRIVATE
firebase_rest_lib
libcurl
)
endif()

if(NOT ANDROID AND NOT IOS)
cpp_pack_library(firebase_http_transport "deps/app")
if(FIREBASE_CPP_BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
Loading
Loading