JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::URL::InputStreamOptions Class Reference

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

#include <juce_URL.h>

Collaboration diagram for juce::URL::InputStreamOptions:

Public Member Functions

 InputStreamOptions (ParameterHandling parameterHandling)
 Constructor. More...
 
int getConnectionTimeoutMs () const noexcept
 
String getExtraHeaders () const noexcept
 
String getHttpRequestCmd () const noexcept
 
int getNumRedirectsToFollow () const noexcept
 
ParameterHandling getParameterHandling () const noexcept
 
std::function< bool(int, int)> getProgressCallback () const noexcept
 
StringPairArraygetResponseHeaders () const noexcept
 
intgetStatusCode () const noexcept
 
JUCE_NODISCARD InputStreamOptions withConnectionTimeoutMs (int connectionTimeoutMs) const
 Specifies a timeout for the request in milliseconds. More...
 
JUCE_NODISCARD InputStreamOptions withExtraHeaders (const String &extraHeaders) const
 A string that will be appended onto the headers that are used for the request. More...
 
JUCE_NODISCARD InputStreamOptions withHttpRequestCmd (const String &httpRequestCmd) const
 Specifies which HTTP request command to use. More...
 
JUCE_NODISCARD InputStreamOptions withNumRedirectsToFollow (int numRedirectsToFollow) const
 Specifies the number of redirects that will be followed before returning a response. More...
 
JUCE_NODISCARD InputStreamOptions withProgressCallback (std::function< bool(int bytesSent, int totalBytes)> progressCallback) const
 A callback function to keep track of the operation's progress. More...
 
JUCE_NODISCARD 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. More...
 
JUCE_NODISCARD 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. More...
 

Private Attributes

int connectionTimeOutMs = 0
 
String extraHeaders
 
String httpRequestCmd
 
int numRedirectsToFollow = 5
 
const ParameterHandling parameterHandling
 
std::function< bool(int, int)> progressCallback = nullptr
 
StringPairArrayresponseHeaders = nullptr
 
intstatusCode = nullptr
 

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")
{
...
}

Constructor & Destructor Documentation

◆ InputStreamOptions()

juce::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.

Member Function Documentation

◆ getConnectionTimeoutMs()

int juce::URL::InputStreamOptions::getConnectionTimeoutMs ( ) const
inlinenoexcept

◆ getExtraHeaders()

String juce::URL::InputStreamOptions::getExtraHeaders ( ) const
inlinenoexcept

◆ getHttpRequestCmd()

String juce::URL::InputStreamOptions::getHttpRequestCmd ( ) const
inlinenoexcept

◆ getNumRedirectsToFollow()

int juce::URL::InputStreamOptions::getNumRedirectsToFollow ( ) const
inlinenoexcept

◆ getParameterHandling()

ParameterHandling juce::URL::InputStreamOptions::getParameterHandling ( ) const
inlinenoexcept

◆ getProgressCallback()

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

◆ getResponseHeaders()

StringPairArray* juce::URL::InputStreamOptions::getResponseHeaders ( ) const
inlinenoexcept

◆ getStatusCode()

int* juce::URL::InputStreamOptions::getStatusCode ( ) const
inlinenoexcept

◆ withConnectionTimeoutMs()

JUCE_NODISCARD InputStreamOptions juce::URL::InputStreamOptions::withConnectionTimeoutMs ( int  connectionTimeoutMs) const

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.

◆ withExtraHeaders()

JUCE_NODISCARD InputStreamOptions juce::URL::InputStreamOptions::withExtraHeaders ( const String extraHeaders) const

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.

◆ withHttpRequestCmd()

JUCE_NODISCARD InputStreamOptions juce::URL::InputStreamOptions::withHttpRequestCmd ( const String httpRequestCmd) const

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.

◆ withNumRedirectsToFollow()

JUCE_NODISCARD InputStreamOptions juce::URL::InputStreamOptions::withNumRedirectsToFollow ( int  numRedirectsToFollow) const

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.

◆ withProgressCallback()

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

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.

◆ withResponseHeaders()

JUCE_NODISCARD InputStreamOptions juce::URL::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.

◆ withStatusCode()

JUCE_NODISCARD InputStreamOptions juce::URL::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.

Member Data Documentation

◆ connectionTimeOutMs

int juce::URL::InputStreamOptions::connectionTimeOutMs = 0
private

◆ extraHeaders

String juce::URL::InputStreamOptions::extraHeaders
private

◆ httpRequestCmd

String juce::URL::InputStreamOptions::httpRequestCmd
private

◆ numRedirectsToFollow

int juce::URL::InputStreamOptions::numRedirectsToFollow = 5
private

◆ parameterHandling

const ParameterHandling juce::URL::InputStreamOptions::parameterHandling
private

◆ progressCallback

std::function<bool (int, int)> juce::URL::InputStreamOptions::progressCallback = nullptr
private

◆ responseHeaders

StringPairArray* juce::URL::InputStreamOptions::responseHeaders = nullptr
private

◆ statusCode

int* juce::URL::InputStreamOptions::statusCode = nullptr
private

The documentation for this class was generated from the following file:
juce::URL::ParameterHandling::inAddress
@ inAddress
juce::URL::InputStreamOptions::withNumRedirectsToFollow
JUCE_NODISCARD InputStreamOptions withNumRedirectsToFollow(int numRedirectsToFollow) const
Specifies the number of redirects that will be followed before returning a response.
juce::URL::createInputStream
std::unique_ptr< InputStream > createInputStream(const InputStreamOptions &options) const
Attempts to open a stream that can read from this URL.
juce::URL::InputStreamOptions::withConnectionTimeoutMs
JUCE_NODISCARD InputStreamOptions withConnectionTimeoutMs(int connectionTimeoutMs) const
Specifies a timeout for the request in milliseconds.
juce::URL::URL
URL()
Creates an empty URL.