Merge branch 'websocket'

This commit is contained in:
Rossen Stoyanchev
2013-05-06 14:46:29 -04:00
117 changed files with 9111 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http;
public interface Cookie {
String getName();
String getValue();
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Cookies {
private final List<Cookie> cookies;
public Cookies() {
this.cookies = new ArrayList<Cookie>();
}
private Cookies(Cookies cookies) {
this.cookies = Collections.unmodifiableList(cookies.getCookies());
}
public static Cookies readOnlyCookies(Cookies cookies) {
return new Cookies(cookies);
}
public List<Cookie> getCookies() {
return this.cookies;
}
public Cookie getCookie(String name) {
for (Cookie c : this.cookies) {
if (c.getName().equals(name)) {
return c;
}
}
return null;
}
public Cookie addCookie(String name, String value) {
DefaultCookie cookie = new DefaultCookie(name, value);
this.cookies.add(cookie);
return cookie;
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http;
import org.springframework.util.Assert;
public class DefaultCookie implements Cookie {
private final String name;
private final String value;
DefaultCookie(String name, String value) {
Assert.hasText(name, "cookie name must not be empty");
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
}

View File

@@ -17,14 +17,10 @@
package org.springframework.http;
import java.io.Serializable;
import java.net.URI;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -40,6 +36,7 @@ import java.util.Set;
import java.util.TimeZone;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
@@ -71,6 +68,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
private static final String CACHE_CONTROL = "Cache-Control";
private static final String CONNECTION = "Connection";
private static final String CONTENT_DISPOSITION = "Content-Disposition";
private static final String CONTENT_LENGTH = "Content-Length";
@@ -91,8 +90,22 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
private static final String LOCATION = "Location";
private static final String ORIGIN = "Origin";
private static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
private static final String SEC_WEBSOCKET_EXTENSIONS = "Sec-WebSocket-Extensions";
private static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
private static final String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol";
private static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
private static final String PRAGMA = "Pragma";
private static final String UPGARDE = "Upgrade";
private static final String[] DATE_FORMATS = new String[] {
"EEE, dd MMM yyyy HH:mm:ss zzz",
@@ -251,6 +264,30 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return getFirst(CACHE_CONTROL);
}
/**
* Sets the (new) value of the {@code Connection} header.
* @param connection the value of the header
*/
public void setConnection(String connection) {
set(CONNECTION, connection);
}
/**
* Sets the (new) value of the {@code Connection} header.
* @param connection the value of the header
*/
public void setConnection(List<String> connection) {
set(CONNECTION, toCommaDelimitedString(connection));
}
/**
* Returns the value of the {@code Connection} header.
* @return the value of the header
*/
public List<String> getConnection() {
return getFirstValueAsList(CONNECTION);
}
/**
* Sets the (new) value of the {@code Content-Disposition} header for {@code form-data}.
* @param name the control name
@@ -393,15 +430,19 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* @param ifNoneMatchList the new value of the header
*/
public void setIfNoneMatch(List<String> ifNoneMatchList) {
set(IF_NONE_MATCH, toCommaDelimitedString(ifNoneMatchList));
}
private String toCommaDelimitedString(List<String> list) {
StringBuilder builder = new StringBuilder();
for (Iterator<String> iterator = ifNoneMatchList.iterator(); iterator.hasNext();) {
for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
String ifNoneMatch = iterator.next();
builder.append(ifNoneMatch);
if (iterator.hasNext()) {
builder.append(", ");
}
}
set(IF_NONE_MATCH, builder.toString());
return builder.toString();
}
/**
@@ -409,9 +450,13 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* @return the header value
*/
public List<String> getIfNoneMatch() {
return getFirstValueAsList(IF_NONE_MATCH);
}
private List<String> getFirstValueAsList(String header) {
List<String> result = new ArrayList<String>();
String value = getFirst(IF_NONE_MATCH);
String value = getFirst(header);
if (value != null) {
String[] tokens = value.split(",\\s*");
for (String token : tokens) {
@@ -457,6 +502,130 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return (value != null ? URI.create(value) : null);
}
/**
* Sets the (new) value of the {@code Origin} header.
* @param origin the value of the header
*/
public void setOrigin(String origin) {
set(ORIGIN, origin);
}
/**
* Returns the value of the {@code Origin} header.
* @return the value of the header
*/
public String getOrigin() {
return getFirst(ORIGIN);
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Accept} header.
* @param secWebSocketAccept the value of the header
*/
public void setSecWebSocketAccept(String secWebSocketAccept) {
set(SEC_WEBSOCKET_ACCEPT, secWebSocketAccept);
}
/**
* Returns the value of the {@code Sec-WebSocket-Accept} header.
* @return the value of the header
*/
public String getSecWebSocketAccept() {
return getFirst(SEC_WEBSOCKET_ACCEPT);
}
/**
* Returns the value of the {@code Sec-WebSocket-Extensions} header.
* @return the value of the header
*/
public List<String> getSecWebSocketExtensions() {
List<String> values = get(SEC_WEBSOCKET_EXTENSIONS);
if (CollectionUtils.isEmpty(values)) {
return Collections.emptyList();
}
else if (values.size() == 1) {
return getFirstValueAsList(SEC_WEBSOCKET_EXTENSIONS);
}
else {
return values;
}
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Extensions} header.
* @param secWebSocketExtensions the value of the header
*/
public void setSecWebSocketExtensions(List<String> secWebSocketExtensions) {
set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(secWebSocketExtensions));
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Key} header.
* @param secWebSocketKey the value of the header
*/
public void setSecWebSocketKey(String secWebSocketKey) {
set(SEC_WEBSOCKET_KEY, secWebSocketKey);
}
/**
* Returns the value of the {@code Sec-WebSocket-Key} header.
* @return the value of the header
*/
public String getSecWebSocketKey() {
return getFirst(SEC_WEBSOCKET_KEY);
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
* @param secWebSocketProtocol the value of the header
*/
public void setSecWebSocketProtocol(String secWebSocketProtocol) {
if (secWebSocketProtocol != null) {
set(SEC_WEBSOCKET_PROTOCOL, secWebSocketProtocol);
}
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
* @param secWebSocketProtocols the value of the header
*/
public void setSecWebSocketProtocol(List<String> secWebSocketProtocols) {
set(SEC_WEBSOCKET_PROTOCOL, toCommaDelimitedString(secWebSocketProtocols));
}
/**
* Returns the value of the {@code Sec-WebSocket-Key} header.
* @return the value of the header
*/
public List<String> getSecWebSocketProtocol() {
List<String> values = get(SEC_WEBSOCKET_PROTOCOL);
if (CollectionUtils.isEmpty(values)) {
return Collections.emptyList();
}
else if (values.size() == 1) {
return getFirstValueAsList(SEC_WEBSOCKET_PROTOCOL);
}
else {
return values;
}
}
/**
* Sets the (new) value of the {@code Sec-WebSocket-Version} header.
* @param secWebSocketKey the value of the header
*/
public void setSecWebSocketVersion(String secWebSocketVersion) {
set(SEC_WEBSOCKET_VERSION, secWebSocketVersion);
}
/**
* Returns the value of the {@code Sec-WebSocket-Version} header.
* @return the value of the header
*/
public String getSecWebSocketVersion() {
return getFirst(SEC_WEBSOCKET_VERSION);
}
/**
* Sets the (new) value of the {@code Pragma} header.
* @param pragma the value of the header
@@ -473,6 +642,22 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return getFirst(PRAGMA);
}
/**
* Sets the (new) value of the {@code Upgrade} header.
* @param upgrade the value of the header
*/
public void setUpgrade(String upgrade) {
set(UPGARDE, upgrade);
}
/**
* Returns the value of the {@code Upgrade} header.
* @return the value of the header
*/
public String getUpgrade() {
return getFirst(UPGARDE);
}
// Utility methods
private long getFirstDate(String headerName) {

View File

@@ -31,4 +31,9 @@ public interface HttpMessage {
*/
HttpHeaders getHeaders();
/**
* TODO ..
*/
Cookies getCookies();
}

View File

@@ -19,6 +19,7 @@ package org.springframework.http.client;
import java.io.IOException;
import java.io.OutputStream;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
@@ -44,6 +45,11 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
return getBodyInternal(this.headers);
}
public Cookies getCookies() {
// TODO
throw new UnsupportedOperationException();
}
public final ClientHttpResponse execute() throws IOException {
checkExecuted();
ClientHttpResponse result = executeInternal(this.headers);

View File

@@ -18,6 +18,7 @@ package org.springframework.http.client;
import java.io.IOException;
import org.springframework.http.Cookies;
import org.springframework.http.HttpStatus;
/**
@@ -32,4 +33,9 @@ public abstract class AbstractClientHttpResponse implements ClientHttpResponse {
return HttpStatus.valueOf(getRawStatusCode());
}
public Cookies getCookies() {
// TODO
throw new UnsupportedOperationException();
}
}

View File

@@ -17,9 +17,9 @@
package org.springframework.http.client;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
@@ -58,4 +58,9 @@ final class BufferingClientHttpRequestWrapper extends AbstractBufferingClientHtt
return new BufferingClientHttpResponseWrapper(response);
}
@Override
public Cookies getCookies() {
return this.request.getCookies();
}
}

View File

@@ -20,9 +20,9 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StreamUtils;
/**
@@ -67,6 +67,10 @@ final class BufferingClientHttpResponseWrapper implements ClientHttpResponse {
return new ByteArrayInputStream(this.body);
}
public Cookies getCookies() {
return this.response.getCookies();
}
public void close() {
this.response.close();
}

View File

@@ -18,6 +18,7 @@ package org.springframework.http.client.support;
import java.net.URI;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
@@ -73,4 +74,11 @@ public class HttpRequestWrapper implements HttpRequest {
return this.request.getHeaders();
}
/**
* Returns the cookies of the wrapped request.
*/
public Cookies getCookies() {
return this.request.getCookies();
}
}

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Random;
import org.springframework.core.io.Resource;
import org.springframework.http.Cookies;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
@@ -383,6 +384,11 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
return this.os;
}
public Cookies getCookies() {
// TODO
throw new UnsupportedOperationException();
}
private void writeHeaders() throws IOException {
if (!this.headersWritten) {
for (Map.Entry<String, List<String>> entry : this.headers.entrySet()) {

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http.server;
/**
* TODO..
*/
public interface AsyncServerHttpRequest extends ServerHttpRequest {
void setTimeout(long timeout);
void startAsync();
boolean isAsyncStarted();
void completeAsync();
boolean isAsyncCompleted();
}

View File

@@ -0,0 +1,149 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http.server;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.util.Assert;
public class AsyncServletServerHttpRequest extends ServletServerHttpRequest
implements AsyncServerHttpRequest, AsyncListener {
private Long timeout;
private AsyncContext asyncContext;
private AtomicBoolean asyncCompleted = new AtomicBoolean(false);
private final List<Runnable> timeoutHandlers = new ArrayList<Runnable>();
private final List<Runnable> completionHandlers = new ArrayList<Runnable>();
private final HttpServletResponse servletResponse;
/**
* Create a new instance for the given request/response pair.
*/
public AsyncServletServerHttpRequest(HttpServletRequest request, HttpServletResponse response) {
super(request);
this.servletResponse = response;
}
/**
* Timeout period begins after the container thread has exited.
*/
public void setTimeout(long timeout) {
Assert.state(!isAsyncStarted(), "Cannot change the timeout with concurrent handling in progress");
this.timeout = timeout;
}
public void addTimeoutHandler(Runnable timeoutHandler) {
this.timeoutHandlers.add(timeoutHandler);
}
public void addCompletionHandler(Runnable runnable) {
this.completionHandlers.add(runnable);
}
public boolean isAsyncStarted() {
return ((this.asyncContext != null) && getServletRequest().isAsyncStarted());
}
/**
* Whether async request processing has completed.
* <p>It is important to avoid use of request and response objects after async
* processing has completed. Servlet containers often re-use them.
*/
public boolean isAsyncCompleted() {
return this.asyncCompleted.get();
}
public void startAsync() {
Assert.state(getServletRequest().isAsyncSupported(),
"Async support must be enabled on a servlet and for all filters involved " +
"in async request processing. This is done in Java code using the Servlet API " +
"or by adding \"<async-supported>true</async-supported>\" to servlet and " +
"filter declarations in web.xml.");
Assert.state(!isAsyncCompleted(), "Async processing has already completed");
if (isAsyncStarted()) {
return;
}
this.asyncContext = getServletRequest().startAsync(getServletRequest(), this.servletResponse);
this.asyncContext.addListener(this);
if (this.timeout != null) {
this.asyncContext.setTimeout(this.timeout);
}
}
public void completeAsync() {
Assert.notNull(this.asyncContext, "Cannot dispatch without an AsyncContext");
if (isAsyncStarted() && !isAsyncCompleted()) {
this.asyncContext.complete();
}
}
// ---------------------------------------------------------------------
// Implementation of AsyncListener methods
// ---------------------------------------------------------------------
@Override
public void onStartAsync(AsyncEvent event) throws IOException {
}
@Override
public void onError(AsyncEvent event) throws IOException {
}
@Override
public void onTimeout(AsyncEvent event) throws IOException {
try {
for (Runnable handler : this.timeoutHandlers) {
handler.run();
}
}
catch (Throwable t) {
// ignore
}
}
@Override
public void onComplete(AsyncEvent event) throws IOException {
try {
for (Runnable handler : this.completionHandlers) {
handler.run();
}
}
catch (Throwable t) {
// ignore
}
this.asyncContext = null;
this.asyncCompleted.set(true);
}
}

View File

@@ -16,8 +16,11 @@
package org.springframework.http.server;
import java.security.Principal;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpRequest;
import org.springframework.util.MultiValueMap;
/**
* Represents a server-side HTTP request.
@@ -27,4 +30,26 @@ import org.springframework.http.HttpRequest;
*/
public interface ServerHttpRequest extends HttpRequest, HttpInputMessage {
/**
* Returns the map of query parameters. Empty if no query has been set.
*/
MultiValueMap<String, String> getQueryParams();
/**
* Return a {@link java.security.Principal} instance containing the name of the
* authenticated user. If the user has not been authenticated, the method returns
* <code>null</code>.
*/
Principal getPrincipal();
/**
* Return the host name of the endpoint on the other end.
*/
String getRemoteHostName();
/**
* Return the IP address of the endpoint on the other end.
*/
String getRemoteAddress();
}

View File

@@ -17,6 +17,7 @@
package org.springframework.http.server;
import java.io.Closeable;
import java.io.IOException;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.HttpStatus;
@@ -35,6 +36,11 @@ public interface ServerHttpResponse extends HttpOutputMessage, Closeable {
*/
void setStatusCode(HttpStatus status);
/**
* TODO
*/
void flush() throws IOException;
/**
* Close this response, freeing any resources created.
*/

View File

@@ -26,6 +26,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.security.Principal;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
@@ -33,12 +34,16 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* {@link ServerHttpRequest} implementation that is based on a {@link HttpServletRequest}.
@@ -58,6 +63,10 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
private HttpHeaders headers;
private Cookies cookies;
private MultiValueMap<String, String> queryParams;
/**
* Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}.
@@ -123,6 +132,45 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
return this.headers;
}
@Override
public Principal getPrincipal() {
return this.servletRequest.getUserPrincipal();
}
@Override
public String getRemoteHostName() {
return this.servletRequest.getRemoteHost();
}
@Override
public String getRemoteAddress() {
return this.servletRequest.getRemoteAddr();
}
public Cookies getCookies() {
if (this.cookies == null) {
this.cookies = new Cookies();
if (this.servletRequest.getCookies() != null) {
for (Cookie cookie : this.servletRequest.getCookies()) {
this.cookies.addCookie(cookie.getName(), cookie.getValue());
}
}
}
return this.cookies;
}
public MultiValueMap<String, String> getQueryParams() {
if (this.queryParams == null) {
this.queryParams = new LinkedMultiValueMap<String, String>(this.servletRequest.getParameterMap().size());
for (String name : this.servletRequest.getParameterMap().keySet()) {
for (String value : this.servletRequest.getParameterValues(name)) {
this.queryParams.add(name, value);
}
}
}
return this.queryParams;
}
public InputStream getBody() throws IOException {
if (isFormPost(this.servletRequest)) {
return getBodyFromServletRequestParameters(this.servletRequest);

View File

@@ -22,6 +22,8 @@ import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.Cookie;
import org.springframework.http.Cookies;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
@@ -40,6 +42,8 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
private boolean headersWritten = false;
private final Cookies cookies = new Cookies();
/**
* Construct a new instance of the ServletServerHttpResponse based on the given {@link HttpServletResponse}.
@@ -66,12 +70,25 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers);
}
public Cookies getCookies() {
return (this.headersWritten ? Cookies.readOnlyCookies(this.cookies) : this.cookies);
}
public OutputStream getBody() throws IOException {
writeCookies();
writeHeaders();
return this.servletResponse.getOutputStream();
}
@Override
public void flush() throws IOException {
writeCookies();
writeHeaders();
this.servletResponse.flushBuffer();
}
public void close() {
writeCookies();
writeHeaders();
}
@@ -95,4 +112,13 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
}
}
private void writeCookies() {
if (!this.headersWritten) {
for (Cookie source : this.cookies.getCookies()) {
javax.servlet.http.Cookie target = new javax.servlet.http.Cookie(source.getName(), source.getValue());
target.setPath("/");
this.servletResponse.addCookie(target);
}
}
}
}