annotate src/org/eclipse/jetty/server/Response.java @ 990:83cc6e05a58f

remove special attribute handling
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 17 Oct 2016 05:50:47 -0600
parents 23ec25435b8c
children 688c39c50ee3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.server;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.io.PrintWriter;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import java.util.Collection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.util.ArrayList;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import java.util.Collections;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import java.util.EnumSet;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import java.util.Enumeration;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import java.util.Locale;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 import javax.servlet.RequestDispatcher;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import javax.servlet.ServletOutputStream;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import javax.servlet.SessionTrackingMode;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import javax.servlet.http.Cookie;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import javax.servlet.http.HttpServletResponse;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import javax.servlet.http.HttpSession;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 import org.eclipse.jetty.http.HttpCookie;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.http.HttpFields;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 import org.eclipse.jetty.http.HttpHeaderValues;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 import org.eclipse.jetty.http.HttpHeaders;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 import org.eclipse.jetty.http.HttpSchemes;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 import org.eclipse.jetty.http.HttpStatus;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 import org.eclipse.jetty.http.HttpURI;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 import org.eclipse.jetty.http.HttpVersions;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 import org.eclipse.jetty.http.MimeTypes;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 import org.eclipse.jetty.io.BufferCache.CachedBuffer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 import org.eclipse.jetty.server.handler.ContextHandler;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 import org.eclipse.jetty.util.ByteArrayISO8859Writer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 import org.eclipse.jetty.util.QuotedStringTokenizer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 import org.eclipse.jetty.util.StringUtil;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 import org.eclipse.jetty.util.URIUtil;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 813
diff changeset
52 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 813
diff changeset
53 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 /** Response.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 * Implements {@link javax.servlet.http.HttpServletResponse} from the <code>javax.servlet.http</code> package.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 public class Response implements HttpServletResponse
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 813
diff changeset
62 private static final Logger LOG = LoggerFactory.getLogger(Response.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
63
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
64
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
65 public static final int
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
66 NONE=0,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
67 STREAM=1,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
68 WRITER=2;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
69
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
70 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
71 * If a header name starts with this string, the header (stripped of the prefix)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
72 * can be set during include using only {@link #setHeader(String, String)} or
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
73 * {@link #addHeader(String, String)}.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
74 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
75 public final static String SET_INCLUDE_HEADER_PREFIX = "org.eclipse.jetty.server.include.";
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
76
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
77 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
78 * If this string is found within the comment of a cookie added with {@link #addCookie(Cookie)}, then the cookie
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
79 * will be set as HTTP ONLY.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
80 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
81 public final static String HTTP_ONLY_COMMENT="__HTTP_ONLY__";
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
82
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
83 private final AbstractHttpConnection _connection;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
84 private int _status=SC_OK;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
85 private String _reason;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
86 private Locale _locale;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
87 private String _mimeType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
88 private CachedBuffer _cachedMimeType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
89 private String _characterEncoding;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
90 private boolean _explicitEncoding;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
91 private String _contentType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
92 private volatile int _outputState;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
93 private PrintWriter _writer;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
94
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
95 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
96 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
97 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
98 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
99 public Response(AbstractHttpConnection connection)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
100 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
101 _connection=connection;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
102 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
103
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
104
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
105 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
106 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
107 * @see javax.servlet.ServletResponse#reset()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
108 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
109 protected void recycle()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
110 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
111 _status=SC_OK;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
112 _reason=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
113 _locale=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
114 _mimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
115 _cachedMimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
116 _characterEncoding=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
117 _explicitEncoding=false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
118 _contentType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
119 _writer=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
120 _outputState=NONE;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
121 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
122
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
123 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
124 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
125 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
126 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
127 public void addCookie(HttpCookie cookie)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
128 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
129 _connection._responseFields.addSetCookie(cookie);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
130 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
131
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
132 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
133 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
134 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
135 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
136 public void addCookie(Cookie cookie)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
137 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
138 String comment=cookie.getComment();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
139 boolean http_only=false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
140
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
141 if (comment!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
142 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
143 int i=comment.indexOf(HTTP_ONLY_COMMENT);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
144 if (i>=0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
145 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
146 http_only=true;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
147 comment=comment.replace(HTTP_ONLY_COMMENT,"").trim();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
148 if (comment.length()==0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
149 comment=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
150 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
151 }
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
152 _connection._responseFields.addSetCookie(cookie.getName(),
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
153 cookie.getValue(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
154 cookie.getDomain(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
155 cookie.getPath(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
156 cookie.getMaxAge(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
157 comment,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
158 cookie.getSecure(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
159 http_only || cookie.isHttpOnly(),
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
160 cookie.getVersion());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
161 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
162
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
163 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
164 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
165 * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
166 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
167 public boolean containsHeader(String name)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
168 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
169 return _connection._responseFields.containsKey(name);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
170 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
171
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
172 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
173 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
174 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
175 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
176 public String encodeURL(String url)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
177 {
809
09d518d313b7 remove SessionManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 throw new UnsupportedOperationException();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
179 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
180
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
181 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
182 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
183 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
184 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
185 public String encodeRedirectURL(String url)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
186 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
187 return encodeURL(url);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
188 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
189
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
190 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
191 @Deprecated
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
192 public String encodeUrl(String url)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
193 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
194 return encodeURL(url);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
195 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
196
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
197 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
198 @Deprecated
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
199 public String encodeRedirectUrl(String url)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
200 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
201 return encodeRedirectURL(url);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
202 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
203
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
204 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
205 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
206 * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
207 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
208 public void sendError(int code, String message) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
209 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
210 if (isCommitted())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
211 LOG.warn("Committed before "+code+" "+message);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
212
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
213 resetBuffer();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
214 _characterEncoding=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
215 setHeader(HttpHeaders.EXPIRES,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
216 setHeader(HttpHeaders.LAST_MODIFIED,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
217 setHeader(HttpHeaders.CACHE_CONTROL,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
218 setHeader(HttpHeaders.CONTENT_TYPE,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
219 setHeader(HttpHeaders.CONTENT_LENGTH,null);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
220
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
221 _outputState=NONE;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
222 setStatus(code,message);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
224 if (message==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
225 message=HttpStatus.getMessage(code);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
226
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
227 // If we are allowed to have a body
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
228 if (code!=SC_NO_CONTENT &&
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
229 code!=SC_NOT_MODIFIED &&
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
230 code!=SC_PARTIAL_CONTENT &&
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
231 code>=SC_OK)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
232 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
233 Request request = _connection.getRequest();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
234
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
235 setHeader(HttpHeaders.CACHE_CONTROL, "must-revalidate,no-cache,no-store");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
236 setContentType(MimeTypes.TEXT_HTML_8859_1);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
237 ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(2048);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
238 if (message != null)
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
239 {
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
240 message= StringUtil.replace(message, "&", "&amp;");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
241 message= StringUtil.replace(message, "<", "&lt;");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
242 message= StringUtil.replace(message, ">", "&gt;");
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
243 }
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
244 String uri= request.getRequestURI();
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
245 if (uri!=null)
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
246 {
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
247 uri= StringUtil.replace(uri, "&", "&amp;");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
248 uri= StringUtil.replace(uri, "<", "&lt;");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
249 uri= StringUtil.replace(uri, ">", "&gt;");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
250 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
251
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
252 writer.write("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\"/>\n");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
253 writer.write("<title>Error ");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
254 writer.write(Integer.toString(code));
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
255 writer.write(' ');
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
256 if (message==null)
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
257 message=HttpStatus.getMessage(code);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
258 writer.write(message);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
259 writer.write("</title>\n</head>\n<body>\n<h2>HTTP ERROR: ");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
260 writer.write(Integer.toString(code));
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
261 writer.write("</h2>\n<p>Problem accessing ");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
262 writer.write(uri);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
263 writer.write(". Reason:\n<pre> ");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
264 writer.write(message);
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
265 writer.write("</pre>");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
266 writer.write("</p>\n<hr /><i><small>Powered by Jetty://</small></i>");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
267
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
268 for (int i= 0; i < 20; i++)
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
269 writer.write("\n ");
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
270 writer.write("\n</body>\n</html>\n");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
271
911
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
272 writer.flush();
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
273 setContentLength(writer.size());
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
274 writer.writeTo(getOutputStream());
cab5830e1ab0 remove ErrorHandler
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
275 writer.destroy();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
276 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
277 else if (code!=SC_PARTIAL_CONTENT)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
278 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
279 _connection._requestFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
280 _connection._requestFields.remove(HttpHeaders.CONTENT_LENGTH_BUFFER);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
281 _characterEncoding=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
282 _mimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
283 _cachedMimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
284 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
285
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
286 complete();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
287 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
288
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
289 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
290 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
291 * @see javax.servlet.http.HttpServletResponse#sendError(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
292 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
293 public void sendError(int sc) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
294 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
295 if (sc==102)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
296 sendProcessing();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
297 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
298 sendError(sc,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
299 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
300
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
301 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
302 /* Send a 102-Processing response.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
303 * If the connection is a HTTP connection, the version is 1.1 and the
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
304 * request has a Expect header starting with 102, then a 102 response is
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
305 * sent. This indicates that the request still be processed and real response
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
306 * can still be sent. This method is called by sendError if it is passed 102.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
307 * @see javax.servlet.http.HttpServletResponse#sendError(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
308 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
309 public void sendProcessing() throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
310 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
311 if (_connection.isExpecting102Processing() && !isCommitted())
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
312 _connection._generator.send1xx(HttpStatus.PROCESSING_102);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
313 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
314
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
315 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
316 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
317 * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
318 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
319 public void sendRedirect(String location) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
320 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
321 if (location==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
322 throw new IllegalArgumentException();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
323
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
324 if (!URIUtil.hasScheme(location))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
325 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
326 StringBuilder buf = _connection.getRequest().getRootURL();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
327 if (location.startsWith("/"))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
328 buf.append(location);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
329 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
330 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
331 String path=_connection.getRequest().getRequestURI();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
332 String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
333 location=URIUtil.addPaths(parent,location);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
334 if(location==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
335 throw new IllegalStateException("path cannot be above root");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
336 if (!location.startsWith("/"))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
337 buf.append('/');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
338 buf.append(location);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
339 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
340
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
341 location=buf.toString();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
342 HttpURI uri = new HttpURI(location);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
343 String path=uri.getDecodedPath();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
344 String canonical=URIUtil.canonicalPath(path);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
345 if (canonical==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
346 throw new IllegalArgumentException();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
347 if (!canonical.equals(path))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
348 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
349 buf = _connection.getRequest().getRootURL();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
350 buf.append(URIUtil.encodePath(canonical));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
351 String param=uri.getParam();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
352 if (param!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
353 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
354 buf.append(';');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
355 buf.append(param);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
356 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
357 String query=uri.getQuery();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
358 if (query!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
359 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
360 buf.append('?');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
361 buf.append(query);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
362 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
363 String fragment=uri.getFragment();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
364 if (fragment!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
365 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
366 buf.append('#');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
367 buf.append(fragment);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
368 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
369 location=buf.toString();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
370 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
371 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
372
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
373 resetBuffer();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
374 setHeader(HttpHeaders.LOCATION,location);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
375 setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
376 complete();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
377
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
378 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
379
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
380 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
381 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
382 * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, long)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
383 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
384 public void setDateHeader(String name, long date)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
385 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
386 _connection._responseFields.putDateField(name, date);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
387 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
388
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
389 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
390 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
391 * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, long)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
392 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
393 public void addDateHeader(String name, long date)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
394 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
395 _connection._responseFields.addDateField(name, date);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
396 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
397
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
398 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
399 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
400 * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
401 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
402 public void setHeader(String name, String value)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
403 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
404 if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
405 setContentType(value);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
406 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
407 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
408 _connection._responseFields.put(name, value);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
409 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
410 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
411 if (value==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
412 _connection._generator.setContentLength(-1);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
413 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
414 _connection._generator.setContentLength(Long.parseLong(value));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
415 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
416 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
417 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
418
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
419
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
420 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
421 public Collection<String> getHeaderNames()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
422 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
423 final HttpFields fields=_connection._responseFields;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
424 return fields.getFieldNamesCollection();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
425 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
426
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
427 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
428 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
429 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
430 public String getHeader(String name)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
431 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
432 return _connection._responseFields.getStringField(name);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
433 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
434
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
435 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
436 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
437 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
438 public Collection<String> getHeaders(String name)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
439 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
440 final HttpFields fields=_connection._responseFields;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
441 Collection<String> i = fields.getValuesCollection(name);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
442 if (i==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
443 return Collections.EMPTY_LIST;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
444 return i;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
445 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
446
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
447 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
448 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
449 * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
450 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
451 public void addHeader(String name, String value)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
452 {
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
453
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
454 if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
455 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
456 setContentType(value);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
457 return;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
458 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
459
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
460 _connection._responseFields.add(name, value);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
461 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
462 _connection._generator.setContentLength(Long.parseLong(value));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
463 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
464
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
465 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
466 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
467 * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
468 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
469 public void setIntHeader(String name, int value)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
470 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
471 _connection._responseFields.putLongField(name, value);
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
472 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name))
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
473 _connection._generator.setContentLength(value);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
474 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
475
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
476 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
477 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
478 * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
479 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
480 public void addIntHeader(String name, int value)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
481 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
482 _connection._responseFields.addLongField(name, value);
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
483 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name))
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
484 _connection._generator.setContentLength(value);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
485 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
486
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
487 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
488 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
489 * @see javax.servlet.http.HttpServletResponse#setStatus(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
490 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
491 public void setStatus(int sc)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
492 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
493 setStatus(sc,null);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
494 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
495
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
496 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
497 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
498 * @see javax.servlet.http.HttpServletResponse#setStatus(int, java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
499 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
500 public void setStatus(int sc, String sm)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
501 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
502 if (sc<=0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
503 throw new IllegalArgumentException();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
504 _status=sc;
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
505 _reason=sm;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
506 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
507
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
508 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
509 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
510 * @see javax.servlet.ServletResponse#getCharacterEncoding()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
511 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
512 public String getCharacterEncoding()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
513 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
514 if (_characterEncoding==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
515 _characterEncoding=StringUtil.__ISO_8859_1;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
516 return _characterEncoding;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
517 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
518
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
519 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
520 String getSetCharacterEncoding()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
521 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
522 return _characterEncoding;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
523 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
524
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
525 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
526 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
527 * @see javax.servlet.ServletResponse#getContentType()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
528 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
529 public String getContentType()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
530 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
531 return _contentType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
532 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
533
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
534 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
535 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
536 * @see javax.servlet.ServletResponse#getOutputStream()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
537 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
538 public ServletOutputStream getOutputStream() throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
539 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
540 if (_outputState!=NONE && _outputState!=STREAM)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
541 throw new IllegalStateException("WRITER");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
542
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
543 ServletOutputStream out = _connection.getOutputStream();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
544 _outputState=STREAM;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
545 return out;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
546 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
547
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
548 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
549 public boolean isWriting()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
550 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
551 return _outputState==WRITER;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
552 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
553
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
554 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
555 public boolean isOutputing()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
556 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
557 return _outputState!=NONE;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
558 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
559
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
560 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
561 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
562 * @see javax.servlet.ServletResponse#getWriter()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
563 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
564 public PrintWriter getWriter() throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
565 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
566 if (_outputState!=NONE && _outputState!=WRITER)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
567 throw new IllegalStateException("STREAM");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
568
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
569 /* if there is no writer yet */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
570 if (_writer==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
571 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
572 /* get encoding from Content-Type header */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
573 String encoding = _characterEncoding;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
574
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
575 if (encoding==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
576 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
577 /* implementation of educated defaults */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
578 if(_cachedMimeType != null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
579 encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
580
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
581 if (encoding==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
582 encoding = StringUtil.__ISO_8859_1;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
583
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
584 setCharacterEncoding(encoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
585 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
586
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
587 /* construct Writer using correct encoding */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
588 _writer = _connection.getPrintWriter(encoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
589 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
590 _outputState=WRITER;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
591 return _writer;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
592 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
593
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
594 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
595 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
596 * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
597 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
598 public void setCharacterEncoding(String encoding)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
599 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
600 if (this._outputState==0 && !isCommitted())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
601 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
602 _explicitEncoding=true;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
603
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
604 if (encoding==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
605 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
606 // Clear any encoding.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
607 if (_characterEncoding!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
608 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
609 _characterEncoding=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
610 if (_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
611 _contentType=_cachedMimeType.toString();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
612 else if (_mimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
613 _contentType=_mimeType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
614 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
615 _contentType=null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
616
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
617 if (_contentType==null)
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
618 _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
619 else
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
620 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
621 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
622 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
623 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
624 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
625 // No, so just add this one to the mimetype
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
626 _characterEncoding=encoding;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
627 if (_contentType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
628 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
629 int i0=_contentType.indexOf(';');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
630 if (i0<0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
631 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
632 _contentType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
633 if(_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
634 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
635 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
636 if (content_type!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
637 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
638 _contentType=content_type.toString();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
639 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
640 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
641 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
642
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
643 if (_contentType==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
644 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
645 _contentType = _mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
646 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
647 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
648 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
649 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
650 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
651 int i1=_contentType.indexOf("charset=",i0);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
652 if (i1<0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
653 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
654 _contentType = _contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
655 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
656 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
657 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
658 int i8=i1+8;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
659 int i2=_contentType.indexOf(" ",i8);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
660 if (i2<0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
661 _contentType=_contentType.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
662 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
663 _contentType=_contentType.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ")+_contentType.substring(i2);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
664 }
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
665 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
666 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
667 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
668 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
669 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
670 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
671
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
672 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
673 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
674 * @see javax.servlet.ServletResponse#setContentLength(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
675 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
676 public void setContentLength(int len)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
677 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
678 // Protect from setting after committed as default handling
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
679 // of a servlet HEAD request ALWAYS sets _content length, even
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
680 // if the getHandling committed the response!
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
681 if (isCommitted())
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
682 return;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
683 _connection._generator.setContentLength(len);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
684 if (len>0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
685 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
686 _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
687 if (_connection._generator.isAllContentWritten())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
688 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
689 if (_outputState==WRITER)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
690 _writer.close();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
691 else if (_outputState==STREAM)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
692 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
693 try
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
694 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
695 getOutputStream().close();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
696 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
697 catch(IOException e)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
698 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
699 throw new RuntimeException(e);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
700 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
701 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
702 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
703 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
704 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
705
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
706 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
707 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
708 * @see javax.servlet.ServletResponse#setContentLength(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
709 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
710 public void setLongContentLength(long len)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
711 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
712 // Protect from setting after committed as default handling
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
713 // of a servlet HEAD request ALWAYS sets _content length, even
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
714 // if the getHandling committed the response!
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
715 if (isCommitted())
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
716 return;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
717 _connection._generator.setContentLength(len);
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
718 _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
719 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
720
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
721 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
722 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
723 * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
724 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
725 public void setContentType(String contentType)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
726 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
727 if (isCommitted())
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
728 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
729
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
730 // Yes this method is horribly complex.... but there are lots of special cases and
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
731 // as this method is called on every request, it is worth trying to save string creation.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
732 //
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
733
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
734 if (contentType==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
735 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
736 if (_locale==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
737 _characterEncoding=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
738 _mimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
739 _cachedMimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
740 _contentType=null;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
741 _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
742 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
743 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
744 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
745 // Look for encoding in contentType
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
746 int i0=contentType.indexOf(';');
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
747
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
748 if (i0>0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
749 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
750 // we have content type parameters
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
751
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
752 // Extract params off mimetype
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
753 _mimeType=contentType.substring(0,i0).trim();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
754 _cachedMimeType=MimeTypes.CACHE.get(_mimeType);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
755
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
756 // Look for charset
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
757 int i1=contentType.indexOf("charset=",i0+1);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
758 if (i1>=0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
759 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
760 _explicitEncoding=true;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
761 int i8=i1+8;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
762 int i2 = contentType.indexOf(' ',i8);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
763
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
764 if (_outputState==WRITER)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
765 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
766 // strip the charset and ignore;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
767 if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' '))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
768 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
769 if (_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
770 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
771 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
772 if (content_type!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
773 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
774 _contentType=content_type.toString();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
775 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
776 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
777 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
778 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
779 _contentType=_mimeType+";charset="+_characterEncoding;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
780 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
781 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
782 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
783 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
784 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
785 _contentType=_mimeType+";charset="+_characterEncoding;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
786 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
787 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
788 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
789 else if (i2<0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
790 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
791 _contentType=contentType.substring(0,i1)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
792 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
793 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
794 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
795 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
796 _contentType=contentType.substring(0,i1)+contentType.substring(i2)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
797 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
798 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
799 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
800 else if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' '))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
801 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
802 // The params are just the char encoding
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
803 _cachedMimeType=MimeTypes.CACHE.get(_mimeType);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
804 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8));
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
805
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
806 if (_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
807 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
808 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
809 if (content_type!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
810 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
811 _contentType=content_type.toString();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
812 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
813 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
814 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
815 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
816 _contentType=contentType;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
817 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
818 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
819 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
820 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
821 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
822 _contentType=contentType;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
823 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
824 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
825 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
826 else if (i2>0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
827 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
828 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8,i2));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
829 _contentType=contentType;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
830 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
831 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
832 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
833 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
834 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
835 _contentType=contentType;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
836 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
837 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
838 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
839 else // No encoding in the params.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
840 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
841 _cachedMimeType=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
842 _contentType=_characterEncoding==null?contentType:contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
843 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
844 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
845 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
846 else // No params at all
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
847 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
848 _mimeType=contentType;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
849 _cachedMimeType=MimeTypes.CACHE.get(_mimeType);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
850
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
851 if (_characterEncoding!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
852 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
853 if (_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
854 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
855 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
856 if (content_type!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
857 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
858 _contentType=content_type.toString();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
859 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
860 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
861 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
862 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
863 _contentType=_mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
864 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
865 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
866 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
867 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
868 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
869 _contentType=contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
870 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
871 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
872 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
873 else if (_cachedMimeType!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
874 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
875 _contentType=_cachedMimeType.toString();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
876 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
877 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
878 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
879 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
880 _contentType=contentType;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
881 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
882 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
883 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
884 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
885 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
886
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
887 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
888 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
889 * @see javax.servlet.ServletResponse#setBufferSize(int)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
890 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
891 public void setBufferSize(int size)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
892 {
983
23ec25435b8c simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents: 982
diff changeset
893 throw new UnsupportedOperationException();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
894 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
895
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
896 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
897 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
898 * @see javax.servlet.ServletResponse#getBufferSize()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
899 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
900 public int getBufferSize()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
901 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
902 return _connection._generator.getContentBufferSize();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
903 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
904
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
905 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
906 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
907 * @see javax.servlet.ServletResponse#flushBuffer()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
908 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
909 public void flushBuffer() throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
910 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
911 _connection.flushResponse();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
912 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
913
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
914 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
915 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
916 * @see javax.servlet.ServletResponse#reset()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
917 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
918 public void reset()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
919 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
920 resetBuffer();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
921 fwdReset();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
922 _status=200;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
923 _reason=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
924
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
925 HttpFields response_fields=_connection._responseFields;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
926
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
927 response_fields.clear();
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
928 String connection=_connection._requestFields.getStringField(HttpHeaders.CONNECTION_BUFFER);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
929 if (connection!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
930 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
931 String[] values = connection.split(",");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
932 for (int i=0;values!=null && i<values.length;i++)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
933 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
934 CachedBuffer cb = HttpHeaderValues.CACHE.get(values[0].trim());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
935
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
936 if (cb!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
937 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
938 switch(cb.getOrdinal())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
939 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
940 case HttpHeaderValues.CLOSE_ORDINAL:
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
941 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE_BUFFER);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
942 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
943
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
944 case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
945 if (HttpVersions.HTTP_1_0.equalsIgnoreCase(_connection.getRequest().getProtocol()))
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
946 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.KEEP_ALIVE);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
947 break;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
948 case HttpHeaderValues.TE_ORDINAL:
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
949 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.TE);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
950 break;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
951 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
952 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
953 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
954 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
955 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
956
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
957
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
958 public void reset(boolean preserveCookies)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
959 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
960 if (!preserveCookies)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
961 reset();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
962 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
963 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
964 HttpFields response_fields=_connection._responseFields;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
965
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
966 ArrayList<String> cookieValues = new ArrayList<String>(5);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
967 Enumeration<String> vals = response_fields.getValues(HttpHeaders.SET_COOKIE);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
968 while (vals.hasMoreElements())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
969 cookieValues.add((String)vals.nextElement());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
970
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
971 reset();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
972
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
973 for (String v:cookieValues)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
974 response_fields.add(HttpHeaders.SET_COOKIE, v);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
975 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
976 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
977
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
978
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
979
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
980 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
981 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
982 * @see javax.servlet.ServletResponse#reset()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
983 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
984 public void fwdReset()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
985 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
986 resetBuffer();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
987
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
988 _writer=null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
989 _outputState=NONE;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
990 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
991
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
992 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
993 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
994 * @see javax.servlet.ServletResponse#resetBuffer()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
995 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
996 public void resetBuffer()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
997 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
998 if (isCommitted())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
999 throw new IllegalStateException("Committed");
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1000 _connection._generator.resetBuffer();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1001 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1002
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1003 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1004 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1005 * @see javax.servlet.ServletResponse#isCommitted()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1006 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1007 public boolean isCommitted()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1008 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1009 return _connection._generator.isCommitted();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1010 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1011
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1012
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1013 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1014 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1015 * @see javax.servlet.ServletResponse#setLocale(java.util.Locale)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1016 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1017 public void setLocale(Locale locale)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1018 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1019 if (locale == null || isCommitted())
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1020 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1021
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1022 _locale = locale;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1023 _connection._responseFields.put(HttpHeaders.CONTENT_LANGUAGE_BUFFER,locale.toString().replace('_','-'));
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1024
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1025 if (_explicitEncoding || _outputState!=0 )
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1026 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1027
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1028 if (_connection.getRequest().getContext()==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1029 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1030
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1031 String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1032
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1033 if (charset!=null && charset.length()>0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1034 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1035 _characterEncoding=charset;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1036
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1037 /* get current MIME type from Content-Type header */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1038 String type=getContentType();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1039 if (type!=null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1040 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1041 _characterEncoding=charset;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1042 int semi=type.indexOf(';');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1043 if (semi<0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1044 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1045 _mimeType=type;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1046 _contentType= type += ";charset="+charset;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1047 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1048 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1049 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1050 _mimeType=type.substring(0,semi);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1051 _contentType= _mimeType += ";charset="+charset;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1052 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1053
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1054 _cachedMimeType=MimeTypes.CACHE.get(_mimeType);
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1055 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1056 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1057 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1058 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1059
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1060 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1061 /*
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1062 * @see javax.servlet.ServletResponse#getLocale()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1063 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1064 public Locale getLocale()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1065 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1066 if (_locale==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1067 return Locale.getDefault();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1068 return _locale;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1069 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1070
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1071 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1072 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1073 * @return The HTTP status code that has been set for this request. This will be <code>200<code>
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1074 * ({@link HttpServletResponse#SC_OK}), unless explicitly set through one of the <code>setStatus</code> methods.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1075 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1076 public int getStatus()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1077 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1078 return _status;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1079 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1080
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1081 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1082 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1083 * @return The reason associated with the current {@link #getStatus() status}. This will be <code>null</code>,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1084 * unless one of the <code>setStatus</code> methods have been called.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1085 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1086 public String getReason()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1087 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1088 return _reason;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1089 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1090
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1091 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1092 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1093 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1094 public void complete()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1095 throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1096 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1097 _connection.completeResponse();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1098 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1099
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1100 /* ------------------------------------------------------------- */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1101 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1102 * @return the number of bytes actually written in response body
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1103 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1104 public long getContentCount()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1105 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1106 if (_connection==null)
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1107 return -1;
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1108 return _connection._generator.getContentWritten();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1109 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1110
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1111 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1112 public HttpFields getHttpFields()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1113 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1114 return _connection._responseFields;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1115 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1116
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1117 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1118 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1119 public String toString()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1120 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1121 return "HTTP/1.1 "+_status+" "+ (_reason==null?"":_reason) +System.getProperty("line.separator")+
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 911
diff changeset
1122 _connection._responseFields.toString();
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1123 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1124
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1125 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1126 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1127 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1128 private static class NullOutput extends ServletOutputStream
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1129 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1130 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1131 public void write(int b) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1132 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1133 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1134
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1135 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1136 public void print(String s) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1137 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1138 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1139
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1140 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1141 public void println(String s) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1142 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1143 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1144
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1145 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1146 public void write(byte[] b, int off, int len) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1147 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1148 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1149
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 809
diff changeset
1150 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1151
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1152 }