Class RequestExecutor

java.lang.Object
com.shri.restinpeace.internal.RequestExecutor

public class RequestExecutor extends Object
Builds and executes the actual HTTP request for a @RestClient method call, applying path/query/header/body parameters and registered RequestInterceptors. Used internally by RestClientInvocationHandler; not part of the library's public API - use RIP instead.

Genuinely separate concerns that grew large enough to earn their own class are delegated out to package-private collaborators instead of living here as private methods: response caching (CacheCoordinator), @FormUrlEncoded body building (FormEncoder), the @Retry loop (RetryExecutor), @Multipart body building (MultipartEncoder), URL template resolution (UrlResolver), response decoding (ResponseDecoder), and interceptor dispatch (InterceptorDispatcher). Every method generated code calls directly (see com.shri.restinpeace.processor.RestClientProcessor) stays here regardless, since generated code's field type is fixed as RequestExecutor - those methods are thin delegates to the collaborator that actually does the work.

  • Constructor Details

    • RequestExecutor

      public RequestExecutor()
      Creates a processor with no runtime base URL override. Cheap and stateless beyond the shared interceptor registry.
    • RequestExecutor

      public RequestExecutor(String baseUrlOverride)
      Creates a processor that resolves every relative method URL against baseUrlOverride instead of the interface's @BaseUrl, for a base URL that's only known at runtime (e.g. per deployment environment). An absolute method URL still ignores this, same as it ignores @BaseUrl. Requests still go through the shared static Unirest client.
      Parameters:
      baseUrlOverride - the runtime base URL, or null to fall back to the interface's @BaseUrl
    • RequestExecutor

      public RequestExecutor(RipClientConfig config)
      Creates a processor from a RipClientConfig. Requests go through a dedicated UnirestInstance - instead of the shared static Unirest client - whenever config sets a connect/read timeout, a proxy, or an objectMapper, since those settings live on a client instance, not per request.
      Parameters:
      config - the per-client settings
  • Method Details

    • useDaemonThreadsForAsync

      public static void useDaemonThreadsForAsync()
      The non-RIP-facing half of RIP.useDaemonThreadsForAsync() - living here (rather than directly in RIP) so the daemon-thread setting can also be applied to a RipClientConfig-backed client's own dedicated UnirestInstance in buildInstance(com.shri.restinpeace.RipClientConfig), not just the shared static Unirest client. Sets a static flag first so every RequestExecutor(RipClientConfig) constructed from this point on picks it up in buildInstance(com.shri.restinpeace.RipClientConfig) too - a config'd client built *before* this is called keeps its own async client as constructed, the same "call once at startup, before building any client" requirement every other global RIP setting already has.
    • addInterceptor

      public static void addInterceptor(RequestInterceptor interceptor)
      Registers a global interceptor applied to every request/response made through RIP. See RIP.addInterceptor(RequestInterceptor).
      Parameters:
      interceptor - the interceptor to register
    • removeInterceptor

      public static void removeInterceptor(RequestInterceptor interceptor)
      Removes one previously registered global interceptor by identity. See RIP.removeInterceptor(RequestInterceptor).
      Parameters:
      interceptor - the interceptor to remove
    • clearInterceptors

      public static void clearInterceptors()
      Removes all registered interceptors.
    • addCallAdapterFactory

      public static void addCallAdapterFactory(CallAdapterFactory factory)
      Registers a global CallAdapterFactory, unless this exact instance (by reference, not equals) is already registered. See RIP.addCallAdapterFactory(CallAdapterFactory). Deliberately identity-based, not equals-based like CopyOnWriteArrayList.addIfAbsent(E): two distinct factory instances that happen to compare equal (a factory class overriding equals) must both still be registered, or the second one's claims would be silently lost.
      Parameters:
      factory - the factory to register
    • removeCallAdapterFactory

      public static void removeCallAdapterFactory(CallAdapterFactory factory)
      Removes one previously registered CallAdapterFactory by identity, not equals - see addCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory)'s own reasoning for why. See RIP.removeCallAdapterFactory(CallAdapterFactory).
      Parameters:
      factory - the factory to remove
    • clearCallAdapterFactories

      public static void clearCallAdapterFactories()
      Removes all registered CallAdapterFactorys.
    • resolveCallAdapter

      public static Optional<CallAdapter<?>> resolveCallAdapter(Method method)
      Consults every registered CallAdapterFactory, in registration order, returning the first non-empty answer - see CallAdapterFactory.get(Method). Public (not package-private, unlike most of this registry) so ReflectiveRestClientValidator can validate a claimed adapter's CallAdapter.responseBodyType() at RIP.getClient(...) time - the same cross-package need PaginationStrategy resolution already has.
      Parameters:
      method - the interface method being dispatched or validated
      Returns:
      the first registered factory's non-empty answer, or Optional.empty() if none claims method
    • addPaginatedCallAdapterFactory

      public static void addPaginatedCallAdapterFactory(PaginatedCallAdapterFactory factory)
      Registers a global PaginatedCallAdapterFactory, unless this exact instance is already registered - identity-based, not equals-based, for the same reason addCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory) is. See RIP.addPaginatedCallAdapterFactory(PaginatedCallAdapterFactory).
      Parameters:
      factory - the factory to register
    • removePaginatedCallAdapterFactory

      public static void removePaginatedCallAdapterFactory(PaginatedCallAdapterFactory factory)
      Parameters:
      factory - the factory to remove
    • clearPaginatedCallAdapterFactories

      public static void clearPaginatedCallAdapterFactories()
      Removes all registered PaginatedCallAdapterFactorys.
    • resolvePaginatedCallAdapter

      public static Optional<PaginatedCallAdapter<?>> resolvePaginatedCallAdapter(Method method)
      Consults every registered PaginatedCallAdapterFactory, in registration order, returning the first non-empty answer - the pagination-aware counterpart of resolveCallAdapter(java.lang.reflect.Method). Public for the same cross-package validation need.
      Parameters:
      method - the @Paginated method being dispatched or validated
      Returns:
      the first registered factory's non-empty answer, or Optional.empty() if none claims method
    • setDefaultCache

      public static void setDefaultCache(Cache cache)
      Sets the shared default cache. See RIP.setCache(Cache).
      Parameters:
      cache - the shared default cache, or null to disable it
    • setDefaultCacheKeyIncludesQueryString

      public static void setDefaultCacheKeyIncludesQueryString(boolean includeQueryString)
      Sets whether the cache key includes the request's query string. See RIP.setCacheKeyIncludesQueryString(boolean).
      Parameters:
      includeQueryString - whether the cache key includes the query string
    • setDefaultNegativeCacheTtlMillis

      public static void setDefaultNegativeCacheTtlMillis(long ttlMillis)
      Sets the shared default negative-cache TTL. See RIP.setNegativeCacheTtlMillis(long).
      Parameters:
      ttlMillis - how long a confirmed 404 stays negatively cached, in milliseconds; must be positive
    • markNoCache

      public void markNoCache(RequestContext context)
      Marks the current call as never cacheable, regardless of any Cache configured for its client - the generated-code counterpart of the reflective path's own @NoCache check. Also used directly by compile-time-generated code for a @NoCache method.
      Parameters:
      context - the call's context, as passed to every other finishGenerated*/applyGenerated* method
    • processRestRequest

      public Object processRestRequest(Method method, HTTPMethod httpMethod, Object[] args)
      Executes the given @RestClient method call and returns its result.
      Parameters:
      method - the interface method that was called
      httpMethod - the HTTP method it maps to
      args - the call's argument values, in declaration order
      Returns:
      the call's result: the raw body, a deserialized object, either wrapped in a RipResponse for its status/headers, a CompletableFuture of any of those, or null for void methods
    • resolveGeneratedUrl

      public String resolveGeneratedUrl(String urlTemplate, String interfaceBaseUrl, String[] pathParamNames, Object[] pathParamValues)
      Resolves a generated method's request URL from its (possibly relative) URL template, substituting @PathParams - the generated-code counterpart of UrlResolver's own resolveUrl, used when the method has no @Url parameter (which bypasses this entirely; see requireUrlParam(java.lang.Object, java.lang.String)).
      Parameters:
      urlTemplate - the method's declared URL, possibly relative and/or containing {name} path param placeholders
      interfaceBaseUrl - the interface's @BaseUrl, or null if it has none
      pathParamNames - the names of every @PathParam on the method
      pathParamValues - the corresponding argument values, in the same order
      Returns:
      the fully-resolved request URL
    • requireUrlParam

      public static String requireUrlParam(Object value, String methodDescription)
      The generated-code counterpart of a method annotated @Url: value used verbatim as the request URL, bypassing resolveGeneratedUrl(java.lang.String, java.lang.String, java.lang.String[], java.lang.Object[]) (and everything it would otherwise resolve - @BaseUrl, a runtime base URL, @PathParam) entirely, mirroring UrlResolver's own resolveUrlParam.
      Parameters:
      value - the @Url parameter's argument value
      methodDescription - the interface and method name, for the exception message if value is missing
      Returns:
      value as a String
    • createGeneratedRequest

      public kong.unirest.HttpRequest<?> createGeneratedRequest(HTTPMethod httpMethod, String url, int connectMillis, int readMillis)
      Builds the request and applies its @Timeout (if any) - the generated-code counterpart of createRequest(HTTPMethod, String) plus applyTimeout(HttpRequest, Method), taking @Timeout's values as literals (or -1, its own "unset" default, for a method with none) instead of a reflective lookup.
      Parameters:
      httpMethod - the HTTP method to issue
      url - the fully-resolved request URL
      connectMillis - @Timeout's connectMillis, or -1 if unset
      readMillis - @Timeout's readMillis, or -1 if unset
      Returns:
      the built, not-yet-executed request
    • applyGeneratedHeaders

      public void applyGeneratedHeaders(kong.unirest.HttpRequest<?> request, String[] headerEntries)
      The generated-code counterpart of applyFixedHeaders(kong.unirest.HttpRequest<?>, java.lang.reflect.Method), taking @Headers' entries as a literal.
      Parameters:
      request - the request to apply the headers to
      headerEntries - @Headers' "Name: Value" entries
    • resolveValue

      public Object resolveValue(Object argValue, boolean required, String defaultValue, String paramName)
      Applies a query param or header value that has @QueryParam/ @HeaderParam's required/defaultValue semantics - shared by the reflective path's applyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext) and generated code, which calls this directly then applies the result itself (applyQueryValue(kong.unirest.HttpRequest<?>, java.lang.String, java.lang.Object) for a query param; request.headerReplace(name, String.valueOf(value)) - a plain public Unirest call - for a header param, so no separate "generated header param" method is needed).
      Parameters:
      argValue - the parameter's argument value, possibly null
      required - @QueryParam/@HeaderParam's required
      defaultValue - @QueryParam/@HeaderParam's defaultValue
      paramName - the query/header name, for the exception message if required and no value or default is available
      Returns:
      argValue if non-null, else defaultValue if set, else null (or a thrown exception if required)
    • applyGeneratedBodyIfPresent

      public kong.unirest.HttpRequest<?> applyGeneratedBodyIfPresent(kong.unirest.HttpRequest<?> request, Object value, RequestContext context)
      The generated-code counterpart of applyBody(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object, com.shri.restinpeace.interceptor.RequestContext), applying a @Body value only if it's non-null.
      Parameters:
      request - the request to apply the body to
      value - the @Body parameter's argument value, or null
      context - this call's context - the body, once known, is stashed on it via RequestContext.setBody(java.lang.String) for an interceptor to read
      Returns:
      request, with the body applied if value was non-null
    • finishGeneratedSync

      public Object finishGeneratedSync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      Executes and decodes a sync request whose return type is void, String, or a POJO - the generated-code counterpart of the plain (non-byte[]/File/RipResponse/ CompletableFuture) branch of processRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[]), applying registered interceptors first.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      returnType - the method's declared return type to decode into
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      the decoded body, or null for a void method
    • finishGeneratedSyncBytes

      public byte[] finishGeneratedSyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      the response body's raw bytes
    • finishGeneratedSyncFile

      public File finishGeneratedSyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      destination - the file to write the response body into
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      destination, with the response body written into it
    • finishGeneratedSyncRipResponse

      public RipResponse<?> finishGeneratedSyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      The generated-code counterpart of processRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'s RipResponse<T>-return branch for a String/POJO T - innerType is T. Erased to RipResponse<?>; generated code casts the result to its own exact RipResponse<T> return type.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      innerType - the class to decode T into
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      the response wrapped with its status code and headers
    • finishGeneratedSyncRipResponseBytes

      public RipResponse<byte[]> finishGeneratedSyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      the response's raw bytes, wrapped with its status code and headers
    • finishGeneratedAsync

      public CompletableFuture<?> finishGeneratedAsync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      The generated-code counterpart of processAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s plain (non-byte[]/File/RipResponse) branch.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      returnType - the class to decode into, once the future completes
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      a future of the decoded body, or of null for a void method
    • finishGeneratedAsyncBytes

      public CompletableFuture<byte[]> finishGeneratedAsyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      The generated-code counterpart of processAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s byte[]-inner-type branch.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      a future of the response body's raw bytes
    • finishGeneratedAsyncFile

      public CompletableFuture<File> finishGeneratedAsyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      The generated-code counterpart of processAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s File-inner-type branch.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      destination - the file to write the response body into
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      a future of destination, with the response body written into it
    • finishGeneratedAsyncRipResponse

      public CompletableFuture<RipResponse<?>> finishGeneratedAsyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      The generated-code counterpart of processAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s RipResponse<T>-inner-type branch for a String/POJO T. Erased to CompletableFuture<RipResponse<?>>; generated code casts the result to its own exact CompletableFuture<RipResponse<T>> return type.
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      innerType - the class to decode T into
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      a future of the response wrapped with its status code and headers
    • finishGeneratedAsyncRipResponseBytes

      public CompletableFuture<RipResponse<byte[]>> finishGeneratedAsyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus)
      Parameters:
      request - the request to execute
      context - the interceptor/logging context for this call
      errorType - the class to decode a non-2xx response's body into, or null for none
      hasRetry - whether the method is annotated @Retry
      retryTimes - @Retry's times, meaningless if hasRetry is false
      retryDelayMillis - @Retry's delayMillis, meaningless if hasRetry is false
      retryBackoffMultiplier - @Retry's backoffMultiplier, meaningless if hasRetry is false
      retryJitterFactor - @Retry's jitterFactor, meaningless if hasRetry is false
      retryOnStatus - @Retry's retryOnStatus, meaningless if hasRetry is false
      Returns:
      a future of the response's raw bytes, wrapped with its status code and headers
    • applyIdempotencyKeyIfNeeded

      public void applyIdempotencyKeyIfNeeded(kong.unirest.HttpRequest<?> request, boolean idempotent)
      Sends a freshly generated Idempotency-Key header when idempotent is true - called once per call, before any attempt is made, so every retry of that call (which re-sends the same request object) carries the identical value. Also used directly by compile-time-generated code for a @Retry(idempotent = true) method.
      Parameters:
      request - the request to add the header to
      idempotent - @Retry's idempotent
    • applyDownloadMonitor

      public void applyDownloadMonitor(kong.unirest.HttpRequest<?> request, DownloadProgressListener listener)
      Also used directly by compile-time-generated code for a DownloadProgressListener parameter.
      Parameters:
      request - the request to monitor
      listener - the listener to notify, or null for none
    • applyUploadMonitor

      public void applyUploadMonitor(kong.unirest.MultipartBody multipartBody, UploadProgressListener listener)
      Also used directly by compile-time-generated code for an UploadProgressListener parameter.
      Parameters:
      multipartBody - the multipart body to monitor
      listener - the listener to notify (callers only invoke this once a non-null listener argument is confirmed)
    • beginGeneratedMultipart

      public kong.unirest.MultipartBody beginGeneratedMultipart(kong.unirest.HttpRequest<?> request)
      The generated-code counterpart of the reflective path's own ((HttpRequestWithBody) request).multiPartContent() call for a @Multipart method - see applyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).
      Parameters:
      request - the request to convert to a multipart body
      Returns:
      request, as a MultipartBody
    • applyPartMap

      public void applyPartMap(kong.unirest.MultipartBody multipartBody, Map<?,?> partMap)
      Also used directly by compile-time-generated code for a @PartMap parameter.
      Parameters:
      multipartBody - the multipart body to add parts to
      partMap - the @PartMap parameter's argument value; a null-valued entry is skipped
    • applyPartValue

      public void applyPartValue(kong.unirest.MultipartBody multipartBody, String name, String fileName, Object value)
      Also used directly by compile-time-generated code for a @Part parameter.
      Parameters:
      multipartBody - the multipart body to add the part to
      name - the part's field name
      fileName - the file name to send a File/byte[]/ InputStream part under, or empty to use name (or, for a File, its own name)
      value - the part's value - a String, File, byte[], InputStream, or a PartValue wrapping one of those with its own file name
    • appendFormFieldMap

      public void appendFormFieldMap(List<String> formFields, Map<?,?> fieldMap)
      Also used directly by compile-time-generated code for a @FieldMap parameter.
      Parameters:
      formFields - the accumulator to append encoded name=value pairs to
      fieldMap - the @FieldMap parameter's argument value; a null-valued entry is skipped
    • appendFormField

      public void appendFormField(List<String> formFields, String name, Object value)
      Appends one @Field/@FieldMap entry to a @FormUrlEncoded method's accumulated body. Also used directly by compile-time-generated code for a @Field parameter.
      Parameters:
      formFields - the accumulator to append encoded name=value pairs to
      name - the field name
      value - the field's value; a Collection is repeated once per non-null element, any other value once via String.valueOf(...)
    • applyFormUrlEncodedBody

      public kong.unirest.HttpRequest<?> applyFormUrlEncodedBody(kong.unirest.HttpRequest<?> request, List<String> formFields)
      Finalizes a @FormUrlEncoded method's accumulated name=value pairs into the request's body - the generated-code counterpart of the reflective path's own finalization in applyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).
      Parameters:
      request - the request to apply the encoded body to
      formFields - the accumulated encoded name=value pairs
      Returns:
      request, with the encoded body applied
    • applyQueryMap

      public void applyQueryMap(kong.unirest.HttpRequest<?> request, Map<?,?> queryMap)
      Also used directly by compile-time-generated code for a @QueryMap parameter.
      Parameters:
      request - the request to add query params to
      queryMap - the @QueryMap parameter's argument value; a null-valued entry is skipped
    • applyQueryValue

      public static void applyQueryValue(kong.unirest.HttpRequest<?> request, String name, Object value)
      Adds a query param, repeating it once per element - instead of once with a single mangled toString() value - when value is a Collection (e.g. a List<String> of tags producing ?tag=a&tag=b), matching Unirest's own queryString(String, Collection) overload that Object-typed dispatch would otherwise never reach. Also used directly by compile-time-generated code for a @QueryParam.
      Parameters:
      request - the request to add the query param to
      name - the query param's name
      value - the query param's value; a Collection is repeated once per element, any other value once via toString()
    • applyHeaderMap

      public void applyHeaderMap(kong.unirest.HttpRequest<?> request, Map<?,?> headerMap)
      Also used directly by compile-time-generated code for a @HeaderMap parameter.
      Parameters:
      request - the request to add headers to
      headerMap - the @HeaderMap parameter's argument value; a null-valued entry is skipped. A Collection value adds one header per element under the same name, matching applyQueryValue(kong.unirest.HttpRequest<?>, java.lang.String, java.lang.Object)'s own handling of a Collection value, instead of one header with a single mangled toString() value.