Search in sources :

Example 1 with MultiplexerUriBuilder

use of com.linkedin.restli.client.uribuilders.MultiplexerUriBuilder in project rest.li by linkedin.

the class RestClient method buildMultiplexedRequest.

private RestRequest buildMultiplexedRequest(MultiplexedRequest multiplexedRequest) throws IOException {
    URI requestUri = new MultiplexerUriBuilder(_uriPrefix).build();
    RestRequestBuilder requestBuilder = new RestRequestBuilder(requestUri).setMethod(HttpMethod.POST.toString());
    addAcceptHeaders(requestBuilder, multiplexedRequest.getRequestOptions().getAcceptTypes(), false);
    final DataMap multiplexedPayload = multiplexedRequest.getContent().data();
    final ContentType type = resolveContentType(requestBuilder, multiplexedPayload, multiplexedRequest.getRequestOptions().getContentType(), requestUri);
    assert (type != null);
    requestBuilder.setHeader(RestConstants.HEADER_CONTENT_TYPE, type.getHeaderKey());
    requestBuilder.setEntity(type.getCodec().mapToByteString(multiplexedPayload));
    requestBuilder.setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion().toString());
    return requestBuilder.build();
}
Also used : ContentType(com.linkedin.restli.common.ContentType) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) MultiplexerUriBuilder(com.linkedin.restli.client.uribuilders.MultiplexerUriBuilder) URI(java.net.URI) DataMap(com.linkedin.data.DataMap)

Aggregations

DataMap (com.linkedin.data.DataMap)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 MultiplexerUriBuilder (com.linkedin.restli.client.uribuilders.MultiplexerUriBuilder)1 ContentType (com.linkedin.restli.common.ContentType)1 URI (java.net.URI)1