/** * Create new outbound message context copying the content * of another context. * * @param original the original outbound message context. */ public OutboundMessageContext(OutboundMessageContext original) { this.headers = HeaderUtils.createOutbound(); this.headers.putAll(original.headers); this.committingOutputStream = new CommittingOutputStream(); this.entityStream = committingOutputStream; this.entity = original.entity; this.entityType = original.entityType; this.entityAnnotations = original.entityAnnotations; }
/** * Create new outbound message context copying the content * of another context. * * @param original the original outbound message context. */ public OutboundMessageContext(OutboundMessageContext original) { this.headers = HeaderUtils.createOutbound(); this.headers.putAll(original.headers); this.committingOutputStream = new CommittingOutputStream(); this.entityStream = committingOutputStream; this.entity = original.entity; this.entityType = original.entityType; this.entityAnnotations = original.entityAnnotations; }
/** * Replace all headers. * * @param headers new headers. */ public void replaceHeaders(MultivaluedMap<String, Object> headers) { getHeaders().clear(); if (headers != null) { getHeaders().putAll(headers); } }
/** * Replace all headers. * * @param headers new headers. */ public void replaceHeaders(MultivaluedMap<String, Object> headers) { getHeaders().clear(); if (headers != null) { getHeaders().putAll(headers); } }
/** * Get an OutboundJaxrsResponse instance for a given JAX-RS response. * * @param response response instance to from. * @return corresponding {@code OutboundJaxrsResponse} instance. */ public static OutboundJaxrsResponse from(javax.ws.rs.core.Response response) { if (response instanceof OutboundJaxrsResponse) { return (OutboundJaxrsResponse) response; } else { final StatusType status = response.getStatusInfo(); final OutboundMessageContext context = new OutboundMessageContext(); context.getHeaders().putAll(response.getMetadata()); context.setEntity(response.getEntity()); return new OutboundJaxrsResponse(status, context); } }
/** * Get an OutboundJaxrsResponse instance for a given JAX-RS response. * * @param response response instance to from. * @return corresponding {@code OutboundJaxrsResponse} instance. */ public static OutboundJaxrsResponse from(javax.ws.rs.core.Response response) { if (response instanceof OutboundJaxrsResponse) { return (OutboundJaxrsResponse) response; } else { final StatusType status = response.getStatusInfo(); final OutboundMessageContext context = new OutboundMessageContext(); context.getHeaders().putAll(response.getMetadata()); context.setEntity(response.getEntity()); return new OutboundJaxrsResponse(status, context); } }
private ClientResponse createClientResponse(final ClientRequest clientRequest, final InMemoryResponseWriter responseWriter) { final ClientResponse clientResponse = new ClientResponse(responseWriter.getStatusInfo(), clientRequest); clientResponse.getHeaders().putAll(responseWriter.getHeaders()); clientResponse.setEntityStream(new ByteArrayInputStream(responseWriter.getEntity())); return clientResponse; }
headers.putAll(nextResponse.getStringHeaders()); response.setStatus(nextResponse.getStatus());
headers.putAll(nextResponse.getStringHeaders()); response.setStatus(nextResponse.getStatus());
headers.putAll(nextResponse.getStringHeaders()); response.setStatus(nextResponse.getStatus());
resp.param(OAuth1Parameters.TOKEN, at.getToken()); resp.param(OAuth1Parameters.TOKEN_SECRET, at.getSecret()); resp.asMap().putAll(at.getAttributes()); return Response.ok(resp).build();
new MapPropertiesDelegate()); requestContext.setEntityStream(exchange.getRequestBody()); requestContext.getHeaders().putAll(exchange.getRequestHeaders()); requestContext.setWriter(responseWriter); try {
public void putAll(Map<? extends K, ? extends List<V>> map) { delegate.putAll(map); }
null, propertiesDelegate); containerRequest.getHeaders().putAll(clientRequest.getStringHeaders());
public PathsTraverser(Id sourceV, Id targetV, Id label, long degree, long capacity, long limit) { this.sources.add(sourceV, new Node(sourceV)); this.targets.add(targetV, new Node(targetV)); this.sourcesAll.putAll(this.sources); this.targetsAll.putAll(this.targets); this.label = label; this.degree = degree; this.capacity = capacity; this.limit = limit; this.count = 0L; }
@Override public Response toResponse(WebApplicationException exception) { Response response = exception.getResponse(); if (response.hasEntity()) { return response; } MultivaluedMap<String, Object> headers = response.getHeaders(); boolean trace = this.trace(response.getStatus()); response = Response.status(response.getStatus()) .type(MediaType.APPLICATION_JSON) .entity(formatException(exception, trace)) .build(); response.getHeaders().putAll(headers); return response; }
protected void enhanceRequest(MockHttpRequest request) { HttpRequest previousRequest = ResteasyContext.getContextData(HttpRequest.class); if (previousRequest != null) { getHeaders(request).putAll(getHeaders(previousRequest)); } }
@SuppressWarnings(value = "unchecked") protected void writePart(OutputStream entityStream, byte[] boundaryBytes, OutputPart part, MultivaluedMap<String, Object> headers) throws IOException { entityStream.write(boundaryBytes); entityStream.write("\r\n".getBytes()); headers.putAll(part.getHeaders()); headers.putSingle(HttpHeaderNames.CONTENT_TYPE, part.getMediaType()); Object entity = part.getEntity(); Class<?> entityType = part.getType(); Type entityGenericType = part.getGenericType(); MessageBodyWriter writer = workers.getMessageBodyWriter(entityType, entityGenericType, null, part.getMediaType()); LogMessages.LOGGER.debugf("MessageBodyWriter: %s", writer.getClass().getName()); OutputStream partStream = new DelegatingOutputStream(entityStream) { @Override public void close() throws IOException { // no close // super.close(); } }; writer.writeTo(entity, entityType, entityGenericType, null, part.getMediaType(), headers, new HeaderFlushedOutputStream(headers, partStream)); entityStream.write("\r\n".getBytes()); } }