default:
throw new IllegalArgumentException("Unsupported enum value: " + _requestOptions.getProtocolVersionOption());
}
URI uri = RestliUriBuilderUtil.createUriBuilder(request, "", protocolVersion).build();
RestRequestBuilder requestBuilder = new RestRequestBuilder(uri);
requestBuilder.setMethod(request.getMethod().getHttpMethod().name());
// unfortunately some headers get set in RestClient, and since we're not using rest client, we
// replicate that behavior here
requestBuilder.setHeader(RestConstants.HEADER_ACCEPT, RestConstants.HEADER_VALUE_APPLICATION_JSON);
requestBuilder.setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, protocolVersion.toString());
if (request.getMethod().getHttpMethod() == HttpMethod.POST)
{
requestBuilder.setHeader(RestConstants.HEADER_RESTLI_REQUEST_METHOD, request.getMethod().toString());
}
if (request.getInputRecord() != null)
{
requestBuilder.setHeader(RestConstants.HEADER_CONTENT_TYPE, RestConstants.HEADER_VALUE_APPLICATION_JSON);
writeEntity(request, protocolVersion, requestBuilder);
}
return requestBuilder.build();
}