is an option for URLRead and related functions to specify advanced connection settings.
ConnectionSettings
is an option for URLRead and related functions to specify advanced connection settings.
Details
- ConnectionSettings takes an association with the following keys:
-
"MaxDownloadSpeed" Automatic maximum allowed download speed "MaxUploadSpeed" Automatic maximum allowed upload speed - Maximum download and upload speed settings are approximate speed settings.
- Maximum download and upload speeds can be given as Quantity expressions.
- Speeds given as integers are interpreted as bytes per second.
Examples
Basic Examples (3)
Download at 12,500 bytes per second:
URLRead["https://www.wolfram.com", "BodyByteArray", ConnectionSettings -> <|"MaxDownloadSpeed" -> 12500|>]//AbsoluteTimingAbsoluteTiming[URLRead["https://www.wolfram.com", "BodyByteArray", ConnectionSettings -> <|"MaxDownloadSpeed" -> Quantity[100, "Kbps"]|>]]AbsoluteTiming[URLRead["https://www.wolfram.com", "BodyByteArray", ConnectionSettings -> <|"MaxDownloadSpeed" -> Quantity[200, "Kbps"]|>]]Create an APIFunction returning the number of characters in a string:
api = APIFunction[{"x" -> "String"}, StringLength[#x]&]Deploy the APIFunction to the cloud:
co = CloudDeploy[api, CloudObject["string-length"], Permissions -> "Public"]url = First[co]longString = StringJoin[ConstantArray["x", 100000]];
StringLength[longString]Upload the string to the API at 400 Kbps:
AbsoluteTiming[
URLRead[
HTTPRequest[url, <|Method -> "POST", "Body" -> {"x" -> longString}|>
], "Body", ConnectionSettings -> <|"MaxUploadSpeed" -> Quantity[400, "Kbps"]|>
]]Upload the string to the API at 800 Kbps:
AbsoluteTiming[
URLRead[
HTTPRequest[url, <|Method -> "POST", "Body" -> {"x" -> longString}|>
], "Body",
ConnectionSettings -> <|"MaxUploadSpeed" -> Quantity[800, "Kbps"]|>
]]The expected time to upload a 100,000 character string at 800 Kbps is about one second:
Quantity[ByteCount[longString], "Bytes"] / Quantity[800., "Kbps"]History
Text
Wolfram Research (2019), ConnectionSettings, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectionSettings.html.
CMS
Wolfram Language. 2019. "ConnectionSettings." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ConnectionSettings.html.
APA
Wolfram Language. (2019). ConnectionSettings. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectionSettings.html
BibTeX
@misc{reference.wolfram_2026_connectionsettings, author="Wolfram Research", title="{ConnectionSettings}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectionSettings.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_connectionsettings, organization={Wolfram Research}, title={ConnectionSettings}, year={2019}, url={https://reference.wolfram.com/language/ref/ConnectionSettings.html}, note=[Accessed: 12-June-2026]}