@SuppressWarnings("deprecation") public GetRequestGroup(Request<?> request, int maxBatchSize) { _baseUriTemplate = request.getBaseUriTemplate(); _headers = request.getHeaders(); _queryParams = getQueryParamsForBatchingKey(request); _resourceSpec = request.getResourceSpec(); _requestOptions = request.getRequestOptions(); _pathKeys = request.getPathKeys(); _maxBatchSize = maxBatchSize; }
if (request.getRequestOptions() != null && request.getRequestOptions().getAcceptResponseAttachments())
private void getProtocolVersionForService(final Request<?> request, Callback<ProtocolVersion> callback) { try { _client.getMetadata(new URI(_uriPrefix + request.getServiceName()), Callbacks.handle(metadata -> callback.onSuccess(getProtocolVersion(AllProtocolVersions.BASELINE_PROTOCOL_VERSION, AllProtocolVersions.PREVIOUS_PROTOCOL_VERSION, AllProtocolVersions.LATEST_PROTOCOL_VERSION, AllProtocolVersions.NEXT_PROTOCOL_VERSION, getAnnouncedVersion(metadata), request.getRequestOptions().getProtocolVersionOption(), _forceUseNextVersionOverride)), callback)); } catch (URISyntaxException e) { throw new RuntimeException("Failed to create a valid URI to fetch properties for!"); } }
@Override public void onSuccess(ProtocolVersion protocolVersion) { URI requestUri = RestliUriBuilderUtil.createUriBuilder(request, _uriPrefix, protocolVersion).build(); final ResourceMethod method = request.getMethod(); final String methodName = request.getMethodName(); addDisruptContext(request.getBaseUriTemplate(), method, methodName, requestContext); sendRestRequestImpl(requestContext, requestUri, method, input != null ? RequestBodyTransformer.transform(request, protocolVersion) : null, request.getHeaders(), CookieUtil.encodeCookies(request.getCookies()), methodName, protocolVersion, request.getRequestOptions(), callback); } });
private <T> void sendRequestNoScatterGather(final Request<T> request, final RequestContext requestContext, final Callback<Response<T>> callback) { //Here we need to decide if we want to use StreamRequest/StreamResponse or RestRequest/RestResponse. //Eventually we will move completely to StreamRequest/StreamResponse for all traffic. //However for the time being we will only use StreamRequest/StreamResponse for traffic that contains attachments. // //Therefore the decision is made as follows: //1. If the content-type OR accept-type is multipart/related then we use StreamRequest/StreamResponse, //otherwise we use RestRequest/RestResponse. //2. The content-type will be decided based on the presence of attachments in the request. //3. The accept-type will be based on the RestLiRequestOptions. //Note that it is not possible for the list of streaming attachments to be non-null and have 0 elements. If the //list of streaming attachments is non null then it must have at least one attachment. The request builders enforce //this invariant. if (_restLiClientConfig.isUseStreaming() || request.getStreamingAttachments() != null || request.getRequestOptions().getAcceptResponseAttachments()) { //Set content type and accept type correctly and use StreamRequest/StreamResponse sendStreamRequest(request, requestContext, new RestLiStreamCallbackAdapter<T>(request.getResponseDecoder(), callback)); } else { sendRestRequest(request, requestContext, new RestLiCallbackAdapter<T>(request.getResponseDecoder(), callback)); } }
@Override public void onSuccess(ProtocolVersion protocolVersion) { URI requestUri = RestliUriBuilderUtil.createUriBuilder(request, _uriPrefix, protocolVersion).build(); final ResourceMethod method = request.getMethod(); final String methodName = request.getMethodName(); addDisruptContext(request.getBaseUriTemplate(), method, methodName, requestContext); sendStreamRequestImpl(requestContext, requestUri, method, input != null ? RequestBodyTransformer.transform(request, protocolVersion) : null, request.getHeaders(), CookieUtil.encodeCookies(request.getCookies()), methodName, protocolVersion, request.getRequestOptions(), request.getStreamingAttachments(), callback); } });