Class BaseStreamRequest<T>

java.lang.Object
com.microsoft.graph.http.BaseStreamRequest<T>
Type Parameters:
T - the class of the response type
All Implemented Interfaces:
IHttpRequest, IHttpStreamRequest

public abstract class BaseStreamRequest<T> extends Object implements IHttpStreamRequest
A request for a binary stream
  • Constructor Details

    • BaseStreamRequest

      public BaseStreamRequest(@Nonnull String requestUrl, @Nonnull IBaseClient<?> client, @Nullable List<? extends Option> options, @Nonnull Class<T> 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

    • sendAsync

      @Nonnull protected CompletableFuture<InputStream> sendAsync()
      Sends this request
      Returns:
      a future with the result
    • send

      @Nullable protected InputStream send() throws ClientException
      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
    • sendAsync

      @Nonnull protected CompletableFuture<T> sendAsync(@Nonnull byte[] fileContents)
      Sends this request
      Parameters:
      fileContents - the file to upload
      Returns:
      a future with the result
    • send

      @Nullable protected T send(@Nonnull byte[] fileContents)
      Sends this request
      Parameters:
      fileContents - the file to upload
      Returns:
      the stream that the caller needs to close
    • getRequestUrl

      @Nullable public URL getRequestUrl()
      Gets the request URL
      Specified by:
      getRequestUrl in interface IHttpRequest
      Returns:
      the request URL
    • getHttpMethod

      @Nullable public HttpMethod getHttpMethod()
      Gets the HTTP method
      Specified by:
      getHttpMethod in interface IHttpRequest
      Returns:
      the HTTP method
    • addHeader

      public void addHeader(@Nonnull String header, @Nullable String value)
      Adds a header to this request
      Specified by:
      addHeader in interface IHttpRequest
      Parameters:
      header - the name of the header
      value - the value of the header
    • setUseCaches

      public void setUseCaches(boolean useCaches)
      Sets useCaches parameter to cache the response
      Specified by:
      setUseCaches in interface IHttpRequest
      Parameters:
      useCaches - the value of useCaches
    • getUseCaches

      public boolean getUseCaches()
      Gets useCaches parameter
      Specified by:
      getUseCaches in interface IHttpRequest
      Returns:
      the value of useCaches
    • getHeaders

      @Nullable public List<HeaderOption> getHeaders()
      Gets the headers
      Specified by:
      getHeaders in interface IHttpRequest
      Returns:
      the headers
    • getOptions

      @Nullable public List<Option> getOptions()
      Gets the query options for this request
      Specified by:
      getOptions in interface IHttpRequest
      Returns:
      the query options for this request
    • setMaxRedirects

      public void setMaxRedirects(int maxRedirects)
      Sets the max redirects
      Specified by:
      setMaxRedirects in interface IHttpRequest
      Parameters:
      maxRedirects - Max redirects that a request can take
    • getMaxRedirects

      public int getMaxRedirects()
      Gets the max redirects
      Specified by:
      getMaxRedirects in interface IHttpRequest
      Returns:
      Max redirects that a request can take
    • setShouldRedirect

      public void setShouldRedirect(@Nonnull IShouldRedirect shouldRedirect)
      Sets the should redirect callback
      Specified by:
      setShouldRedirect in interface IHttpRequest
      Parameters:
      shouldRedirect - Callback called before doing a redirect
    • getShouldRedirect

      @Nonnull public IShouldRedirect getShouldRedirect()
      Gets the should redirect callback
      Specified by:
      getShouldRedirect in interface IHttpRequest
      Returns:
      Callback which is called before redirect
    • setShouldRetry

      public void setShouldRetry(@Nonnull IShouldRetry shouldretry)
      Sets the should retry callback
      Specified by:
      setShouldRetry in interface IHttpRequest
      Parameters:
      shouldretry - The callback called before retry
    • getShouldRetry

      @Nonnull public IShouldRetry getShouldRetry()
      Gets the should retry callback
      Specified by:
      getShouldRetry in interface IHttpRequest
      Returns:
      Callback called before retry
    • setMaxRetries

      public void setMaxRetries(int maxRetries)
      Sets the max retries
      Specified by:
      setMaxRetries in interface IHttpRequest
      Parameters:
      maxRetries - Max retries for a request
    • getMaxRetries

      public int getMaxRetries()
      Gets max retries
      Specified by:
      getMaxRetries in interface IHttpRequest
      Returns:
      Max retries for a request
    • setDelay

      public void setDelay(long delay)
      Sets the delay in seconds between retires
      Specified by:
      setDelay in interface IHttpRequest
      Parameters:
      delay - Delay in seconds between retries
    • getDelay

      public long getDelay()
      Gets delay between retries
      Specified by:
      getDelay in interface IHttpRequest
      Returns:
      Delay between retries in seconds
    • withHttpMethod

      @Nullable public IHttpRequest withHttpMethod(@Nonnull HttpMethod httpMethod)
      Sets the HTTP method and returns the current request
      Specified by:
      withHttpMethod in interface IHttpRequest
      Parameters:
      httpMethod - the HTTP method
      Returns:
      the current request
    • getHttpRequest

      @Nullable public <requestBodyType, responseType, nativeRequestType> nativeRequestType getHttpRequest(@Nullable requestBodyType serializedObject) throws ClientException
      Returns the Request object to be executed
      Specified by:
      getHttpRequest in interface IHttpRequest
      Type Parameters:
      requestBodyType - the type of the serialized object
      responseType - the type of the response
      nativeRequestType - type of a request for the native http client
      Parameters:
      serializedObject - the object to serialize at the body of the request
      Returns:
      the Request object to be executed
      Throws:
      ClientException