Loading...
Searching...
No Matches
URL::InputStreamOptions Class Reference

Class used to create a set of options to pass to the createInputStream() method. More...

Public Member Functions

 InputStreamOptions (ParameterHandling parameterHandling)
 Constructor.
 
InputStreamOptions withProgressCallback (std::function< bool(int bytesSent, int totalBytes)> progressCallback) const
 A callback function to keep track of the operation's progress.
 
InputStreamOptions withExtraHeaders (const String &extraHeaders) const
 A string that will be appended onto the headers that are used for the request.
 
InputStreamOptions withConnectionTimeoutMs (int connectionTimeoutMs) const
 Specifies a timeout for the request in milliseconds.
 
InputStreamOptions withResponseHeaders (StringPairArray *responseHeaders) const
 If this is non-null, all the (key, value) pairs received as headers in the response will be stored in this array.
 
InputStreamOptions withStatusCode (int *statusCode) const
 If this is non-null, it will get set to the http status code, if one is known, or 0 if a code isn't available.
 
InputStreamOptions withNumRedirectsToFollow (int numRedirectsToFollow) const
 Specifies the number of redirects that will be followed before returning a response.
 
InputStreamOptions withHttpRequestCmd (const String &httpRequestCmd) const
 Specifies which HTTP request command to use.
 
ParameterHandling getParameterHandling () const noexcept
 
std::function< bool(int, int)> getProgressCallback () const noexcept
 
String getExtraHeaders () const noexcept
 
int getConnectionTimeoutMs () const noexcept
 
StringPairArraygetResponseHeaders () const noexcept
 
int * getStatusCode () const noexcept
 
int getNumRedirectsToFollow () const noexcept
 
String getHttpRequestCmd () const noexcept
 

Detailed Description

Class used to create a set of options to pass to the createInputStream() method.

You can chain together a series of calls to this class's methods to create a set of whatever options you want to specify, e.g.

if (auto inputStream = URL ("http://www.xyz.com/foobar")
{
...
}
Class used to create a set of options to pass to the createInputStream() method.
Definition juce_URL.h:353
InputStreamOptions withNumRedirectsToFollow(int numRedirectsToFollow) const
Specifies the number of redirects that will be followed before returning a response.
InputStreamOptions withConnectionTimeoutMs(int connectionTimeoutMs) const
Specifies a timeout for the request in milliseconds.
std::unique_ptr< InputStream > createInputStream(const InputStreamOptions &options) const
Attempts to open a stream that can read from this URL.
URL()
Creates an empty URL.
@ inAddress
Definition juce_URL.h:334

Constructor & Destructor Documentation

◆ InputStreamOptions()

URL::InputStreamOptions::InputStreamOptions ( ParameterHandling parameterHandling)
explicit

Constructor.

If parameterHandling is ParameterHandling::inPostData, any URL parameters that have been set will be transferred via the request body data. Otherwise the parameters will be added to the URL address.

Referenced by withConnectionTimeoutMs(), withExtraHeaders(), withHttpRequestCmd(), withNumRedirectsToFollow(), withProgressCallback(), withResponseHeaders(), and withStatusCode().

Member Function Documentation

◆ withProgressCallback()

InputStreamOptions URL::InputStreamOptions::withProgressCallback ( std::function< bool(int bytesSent, int totalBytes)> progressCallback) const
nodiscard

A callback function to keep track of the operation's progress.

This can be useful for lengthy POST operations, so that you can provide user feedback.

References InputStreamOptions().

◆ withExtraHeaders()

InputStreamOptions URL::InputStreamOptions::withExtraHeaders ( const String & extraHeaders) const
nodiscard

A string that will be appended onto the headers that are used for the request.

It must be a valid set of HTML header directives, separated by newlines.

References InputStreamOptions().

◆ withConnectionTimeoutMs()

InputStreamOptions URL::InputStreamOptions::withConnectionTimeoutMs ( int connectionTimeoutMs) const
nodiscard

Specifies a timeout for the request in milliseconds.

If 0, this will use whatever default setting the OS chooses. If a negative number, it will be infinite.

References InputStreamOptions().

◆ withResponseHeaders()

InputStreamOptions URL::InputStreamOptions::withResponseHeaders ( StringPairArray * responseHeaders) const
nodiscard

If this is non-null, all the (key, value) pairs received as headers in the response will be stored in this array.

References InputStreamOptions().

◆ withStatusCode()

InputStreamOptions URL::InputStreamOptions::withStatusCode ( int * statusCode) const
nodiscard

If this is non-null, it will get set to the http status code, if one is known, or 0 if a code isn't available.

References InputStreamOptions().

◆ withNumRedirectsToFollow()

InputStreamOptions URL::InputStreamOptions::withNumRedirectsToFollow ( int numRedirectsToFollow) const
nodiscard

Specifies the number of redirects that will be followed before returning a response.

N.B. This will be ignored on Android which follows up to 5 redirects.

References InputStreamOptions().

◆ withHttpRequestCmd()

InputStreamOptions URL::InputStreamOptions::withHttpRequestCmd ( const String & httpRequestCmd) const
nodiscard

Specifies which HTTP request command to use.

If this is not set, then the command will be POST if parameterHandling is set to ParameterHandling::inPostData or if any POST data has been specified via withPOSTData(), withFileToUpload(), or withDataToUpload(). Otherwise it will be GET.

References InputStreamOptions().

◆ getParameterHandling()

ParameterHandling URL::InputStreamOptions::getParameterHandling ( ) const
noexcept

◆ getProgressCallback()

std::function< bool(int, int)> URL::InputStreamOptions::getProgressCallback ( ) const
noexcept

◆ getExtraHeaders()

String URL::InputStreamOptions::getExtraHeaders ( ) const
noexcept

◆ getConnectionTimeoutMs()

int URL::InputStreamOptions::getConnectionTimeoutMs ( ) const
noexcept

◆ getResponseHeaders()

StringPairArray * URL::InputStreamOptions::getResponseHeaders ( ) const
noexcept

◆ getStatusCode()

int * URL::InputStreamOptions::getStatusCode ( ) const
noexcept

◆ getNumRedirectsToFollow()

int URL::InputStreamOptions::getNumRedirectsToFollow ( ) const
noexcept

◆ getHttpRequestCmd()

String URL::InputStreamOptions::getHttpRequestCmd ( ) const
noexcept
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram