BaseStreamRequest<T> Class

  • java.lang.Object
    • com.microsoft.graph.http.BaseStreamRequest<T>

Type Parameters

T

the class of the response type

Implements

public abstract class BaseStreamRequest<T>
implements IHttpStreamRequest

A request for a binary stream

Constructor Summary

Constructor Description
BaseStreamRequest(String requestUrl, IBaseClient<?> client, List<? extends Option> options, Class<T> responseClass)

Creates the stream request.

Method Summary

Modifier and Type Method and Description
nativeRequestType <requestBodyType,responseType,nativeRequestType>getHttpRequest(requestBodyType serializedObject)

Returns the Request object to be executed

void addHeader(String header, String value)

Adds a header to this request

long getDelay()

Gets delay between retries

java.util.List<HeaderOption> getHeaders()

Gets the headers

HttpMethod getHttpMethod()

Gets the HTTP method

int getMaxRedirects()

Gets the max redirects

int getMaxRetries()

Gets max retries

java.util.List<Option> getOptions()

Gets the query options for this request

java.net.URL getRequestUrl()

Gets the request URL

IShouldRedirect getShouldRedirect()

Gets the should redirect callback

IShouldRetry getShouldRetry()

Gets the should retry callback

boolean getUseCaches()

Gets useCaches parameter

protected java.io.InputStream send()

Sends this request

protected T send(byte[] fileContents)

Sends this request

protected java.util.concurrent.CompletableFuture<java.io.InputStream> sendAsync()

Sends this request

protected java.util.concurrent.CompletableFuture<T> sendAsync(byte[] fileContents)

Sends this request

void setDelay(long delay)

Sets the delay in seconds between retires

void setMaxRedirects(int maxRedirects)

Sets the max redirects

void setMaxRetries(int maxRetries)

Sets the max retries

void setShouldRedirect(IShouldRedirect shouldRedirect)

Sets the should redirect callback

void setShouldRetry(IShouldRetry shouldretry)

Sets the should retry callback

void setUseCaches(boolean useCaches)

Sets useCaches parameter to cache the response

IHttpRequest withHttpMethod(HttpMethod httpMethod)

Sets the HTTP method and returns the current request

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

BaseStreamRequest

public BaseStreamRequest(String requestUrl, IBaseClient client, List options, Class responseClass)

Creates the stream request.

Parameters:

requestUrl - the URL to make the request against
client - the client which can issue the request
options - the options for this request
responseClass - the class for the response

Method Details

<requestBodyType,responseType,nativeRequestType>getHttpRequest

public nativeRequestType getHttpRequest(requestBodyType serializedObject)

Returns the Request object to be executed

Parameters:

serializedObject - the object to serialize at the body of the request

Returns:

the Request object to be executed

Throws:

addHeader

public void addHeader(String header, String value)

Adds a header to this request

Parameters:

header - the name of the header
value - the value of the header

getDelay

public long getDelay()

Gets delay between retries

Returns:

Delay between retries in seconds

getHeaders

public List getHeaders()

Gets the headers

Returns:

the headers

getHttpMethod

public HttpMethod getHttpMethod()

Gets the HTTP method

Returns:

the HTTP method

getMaxRedirects

public int getMaxRedirects()

Gets the max redirects

Returns:

Max redirects that a request can take

getMaxRetries

public int getMaxRetries()

Gets max retries

Returns:

Max retries for a request

getOptions

public List

Gets the query options for this request

Returns:

the query options for this request

getRequestUrl

public URL getRequestUrl()

Gets the request URL

Returns:

the request URL

getShouldRedirect

public IShouldRedirect getShouldRedirect()

Gets the should redirect callback

Returns:

Callback which is called before redirect

getShouldRetry

public IShouldRetry getShouldRetry()

Gets the should retry callback

Returns:

Callback called before retry

getUseCaches

public boolean getUseCaches()

Gets useCaches parameter

Returns:

the value of useCaches

send

protected InputStream send()

Sends this request

Returns:

the stream that the caller needs to close

Throws:

ClientException - an exception occurs if there was an error while the request was sent

send

protected T send(byte[] fileContents)

Sends this request

Parameters:

fileContents - the file to upload

Returns:

the stream that the caller needs to close

sendAsync

protected CompletableFuture sendAsync()

Sends this request

Returns:

a future with the result

sendAsync

protected CompletableFuture sendAsync(byte[] fileContents)

Sends this request

Parameters:

fileContents - the file to upload

Returns:

a future with the result

setDelay

public void setDelay(long delay)

Sets the delay in seconds between retires

Parameters:

delay - Delay in seconds between retries

setMaxRedirects

public void setMaxRedirects(int maxRedirects)

Sets the max redirects

Parameters:

maxRedirects - Max redirects that a request can take

setMaxRetries

public void setMaxRetries(int maxRetries)

Sets the max retries

Parameters:

maxRetries - Max retries for a request

setShouldRedirect

public void setShouldRedirect(IShouldRedirect shouldRedirect)

Sets the should redirect callback

Parameters:

shouldRedirect - Callback called before doing a redirect

setShouldRetry

public void setShouldRetry(IShouldRetry shouldretry)

Sets the should retry callback

Parameters:

shouldretry - The callback called before retry

setUseCaches

public void setUseCaches(boolean useCaches)

Sets useCaches parameter to cache the response

Parameters:

useCaches - the value of useCaches

withHttpMethod

public IHttpRequest withHttpMethod(HttpMethod httpMethod)

Sets the HTTP method and returns the current request

Parameters:

httpMethod - the HTTP method

Returns:

the current request

Applies to