@Override public MultivaluedMap<String, String> getStringHeaders() { return invocation.getHeaders().asMap(); }
@Override public List<MediaType> getAcceptableMediaTypes() { List<MediaType> rtn = invocation.getHeaders().getAcceptableMediaTypes(); if (rtn.size() == 0) { rtn = new ArrayList<MediaType>(); rtn.add(MediaType.WILDCARD_TYPE); } return rtn; }
protected ClientInvocation(final ClientInvocation clientInvocation) { this.client = clientInvocation.client; this.configuration = new ClientConfiguration(clientInvocation.configuration); this.headers = new ClientRequestHeaders(this.configuration); MultivaluedTreeMap.copy(clientInvocation.headers.getHeaders(), this.headers.headers); this.method = clientInvocation.method; this.entity = clientInvocation.entity; this.entityGenericType = clientInvocation.entityGenericType; this.entityClass = clientInvocation.entityClass; this.entityAnnotations = clientInvocation.entityAnnotations; this.uri = clientInvocation.uri; this.chunked = clientInvocation.chunked; this.tracingLogger = clientInvocation.tracingLogger; }
public void header(String name, Object value) { if (value == null) { headers.remove(name); return; } if (name.equalsIgnoreCase(HttpHeaders.ACCEPT)) accept(configuration.toHeaderString(value)); else if (name.equalsIgnoreCase(HttpHeaders.ACCEPT_ENCODING)) acceptEncoding(configuration.toHeaderString(value)); else if (name.equalsIgnoreCase(HttpHeaders.ACCEPT_LANGUAGE)) acceptLanguage(configuration.toHeaderString(value)); else headers.add(name, value); }
@Override public MediaType getMediaType() { return invocation.getHeaders().getMediaType(); }
public void writeRequestBody(OutputStream outputStream) throws IOException { if (entity == null) { return; } WriterInterceptor[] interceptors = getWriterInterceptors(); AbstractWriterInterceptorContext ctx = new ClientWriterInterceptorContext(interceptors, configuration.getProviderFactory(), entity, entityClass, entityGenericType, entityAnnotations, headers.getMediaType(), headers.getHeaders(), outputStream, getMutableProperties(), tracingLogger); final long timestamp = tracingLogger.timestamp("WI_SUMMARY"); try { ctx.proceed(); } finally { tracingLogger.logDuration("WI_SUMMARY", timestamp, ctx.getProcessedInterceptorCount()); } }
public void acceptLanguage(String... locales) { String accept = (String)headers.getFirst(HttpHeaders.ACCEPT_LANGUAGE); StringBuilder builder = buildAcceptString(accept, locales); headers.putSingle(HttpHeaders.ACCEPT_LANGUAGE, builder.toString()); }
@Override public Invocation.Builder accept(MediaType... mediaTypes) { getHeaders().accept(mediaTypes); return this; }
protected ClientInvocation createRequest(Object[] args, Request request) { ClientInvocation inv = super.createRequest(args); RestfulUtil.encodeAttachments(inv.getHeaders().getHeaders(), request.getAttachments()); return inv; }
@Override public Invocation.Builder acceptLanguage(Locale... locales) { getHeaders().acceptLanguage(locales); return this; }
protected ClientInvocation createRequest(Object[] args) { WebTarget target = this.webTarget; for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof WebTargetProcessor) { WebTargetProcessor processor = (WebTargetProcessor)processors[i]; target = processor.build(target, args[i]); } } ClientConfiguration parentConfiguration=(ClientConfiguration) target.getConfiguration(); ClientInvocation clientInvocation = new ClientInvocation(this.webTarget.getResteasyClient(), target.getUri(), new ClientRequestHeaders(parentConfiguration), parentConfiguration); clientInvocation.setClientInvoker(this); if (accepts != null) { clientInvocation.getHeaders().accept(accepts); } for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof InvocationProcessor) { InvocationProcessor processor = (InvocationProcessor)processors[i]; processor.process(clientInvocation, args[i]); } } clientInvocation.setMethod(httpMethod); return clientInvocation; }
public ClientInvocationBuilder(final ResteasyClient client, final URI uri, final ClientConfiguration configuration) { invocation = createClientInvocation(client, uri, new ClientRequestHeaders(configuration), configuration); this.uri = uri; }
@Override public Invocation.Builder cacheControl(CacheControl cacheControl) { getHeaders().cacheControl(cacheControl); return this; }
@Override public Invocation.Builder acceptEncoding(String... encodings) { getHeaders().acceptEncoding(encodings); return this; }
public void header(String name, Object value) { if (value == null) { headers.remove(name); return; } if (name.equalsIgnoreCase(HttpHeaders.ACCEPT)) accept(configuration.toHeaderString(value)); else if (name.equalsIgnoreCase(HttpHeaders.ACCEPT_ENCODING)) acceptEncoding(configuration.toHeaderString(value)); else if (name.equalsIgnoreCase(HttpHeaders.ACCEPT_LANGUAGE)) acceptLanguage(configuration.toHeaderString(value)); else headers.add(name, value); }
.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getHeaders().getMediaType().toString())); entityToBuild = entityToBuildByteArray; request.getHeaders().getMediaType().toString());
public void writeRequestBody(OutputStream outputStream) throws IOException { if (entity == null) { return; } WriterInterceptor[] interceptors = getWriterInterceptors(); AbstractWriterInterceptorContext ctx = new ClientWriterInterceptorContext(interceptors, configuration.getProviderFactory(), entity, entityClass, entityGenericType, entityAnnotations, headers.getMediaType(), headers.getHeaders(), outputStream, getMutableProperties()); ctx.proceed(); }
public void acceptLanguage(Locale... locales) { String accept = (String)headers.getFirst(HttpHeaders.ACCEPT_LANGUAGE); StringBuilder builder = buildAcceptString(accept, locales); headers.putSingle(HttpHeaders.ACCEPT_LANGUAGE, builder.toString()); }
@Override public Invocation.Builder accept(String... mediaTypes) { getHeaders().accept(mediaTypes); return this; }
@Override public MultivaluedMap<String, Object> getHeaders() { return invocation.getHeaders().getHeaders(); }