bAllowSeekFunction

bAllowSeekFunction

#Overview

name: bAllowSeekFunction

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bAllowSeekFunction is to control whether seek functionality is enabled for HTTP requests using the cURL library in Unreal Engine 5. This setting is primarily used in the HTTP subsystem, specifically within the cURL implementation of HTTP requests.

This setting variable is relied upon by the HTTP module, particularly in the cURL-based HTTP implementation. It’s used in both the FCurlHttpRequest and FCurlHttpManager classes, which are part of the HTTP subsystem in Unreal Engine.

The value of this variable is set through the configuration system. It’s read from the “HTTP.Curl” section of the GEngineIni file using the GConfig->GetBool() function. This happens in the FCurlHttpManager::InitCurl() and FCurlHttpManager::UpdateConfigs() functions.

The bAllowSeekFunction variable interacts with the bIsRequestPayloadSeekable variable in the context of setting up cURL options for HTTP requests. When both are true, it enables seek functionality for the request payload.

Developers must be aware that this setting affects the behavior of HTTP requests, particularly those with payloads that might benefit from seek functionality. Enabling this option can provide more flexibility in handling request payloads, but it may also have performance implications.

Best practices when using this variable include:

  1. Only enable it if seek functionality is necessary for your HTTP requests.
  2. Consider the performance impact of enabling seek functionality, especially for large numbers of requests or large payloads.
  3. Ensure that the payloads you’re sending are actually seekable (bIsRequestPayloadSeekable) before relying on this functionality.
  4. Be aware that changing this setting at runtime (through UpdateConfigs()) will only affect new requests, not ongoing ones.
  5. Monitor and log any changes to this setting, as demonstrated in the UpdateConfigs() function, to track configuration changes that might affect application behavior.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:50, section: [HTTP.Curl]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttp.cpp:987

Scope (from outer to inner):

file
function     bool FCurlHttpRequest::SetupRequestHttpThread

Source code excerpt:

		curl_easy_setopt(EasyHandle, CURLOPT_CONNECTTIMEOUT, HttpConnectionTimeout);

		if (FCurlHttpManager::CurlRequestOptions.bAllowSeekFunction && bIsRequestPayloadSeekable)
		{
			curl_easy_setopt(EasyHandle, CURLOPT_SEEKDATA, this);
			curl_easy_setopt(EasyHandle, CURLOPT_SEEKFUNCTION, StaticSeekCallback);
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttpManager.cpp:273

Scope (from outer to inner):

file
function     void FCurlHttpManager::InitCurl

Source code excerpt:

	}

	GConfig->GetBool(TEXT("HTTP.Curl"), TEXT("bAllowSeekFunction"), CurlRequestOptions.bAllowSeekFunction, GEngineIni);

	CurlRequestOptions.MaxHostConnections = FHttpModule::Get().GetHttpMaxConnectionsPerServer();
	if (CurlRequestOptions.MaxHostConnections > 0)
	{
		const CURLMcode SetOptResult = curl_multi_setopt(GMultiHandle, CURLMOPT_MAX_HOST_CONNECTIONS, static_cast<long>(CurlRequestOptions.MaxHostConnections));
		if (SetOptResult != CURLM_OK)

#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttpManager.cpp:434

Scope (from outer to inner):

file
function     void FCurlHttpManager::UpdateConfigs

Source code excerpt:

	{
		bool bConfigAllowSeekFunction = false;
		if (GConfig->GetBool(TEXT("HTTP.Curl"), TEXT("bAllowSeekFunction"), bConfigAllowSeekFunction, GEngineIni))
		{
			if (CurlRequestOptions.bAllowSeekFunction != bConfigAllowSeekFunction)
			{
				UE_LOG(LogHttp, Log, TEXT("bAllowSeekFunction changed from %s to %s"), *LexToString(CurlRequestOptions.bAllowSeekFunction), *LexToString(bConfigAllowSeekFunction));
				CurlRequestOptions.bAllowSeekFunction = bConfigAllowSeekFunction;
			}
		}
	}
}

FHttpThreadBase* FCurlHttpManager::CreateHttpThread()

#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttpManager.h:62

Scope (from outer to inner):

file
class        class FCurlHttpManager : public FHttpManager

Source code excerpt:


		/** Do we allow seeking? */
		bool bAllowSeekFunction = false;
	}
	CurlRequestOptions;

	//~ Begin HttpManager Interface
	virtual void OnBeforeFork() override;
	virtual void OnAfterFork() override;