/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class ExchangeImpl {
boolean writefinished;
long reqContentLen;
long rspContentLen;
/* raw streams which access the socket directly */
/* close the underlying connection when this exchange finished */
boolean close;
boolean closed;
boolean http10 = false;
/* for formatting the Date: header */
new ThreadLocal<DateFormat>() {
return df;
}
};
/* streams which take care of the HTTP protocol framing
* and are passed up to higher layers
*/
) throws IOException {
this.method = m;
this.uri = u;
this.connection = connection;
this.reqContentLen = len;
/* ros only used for headers, body written directly to stream */
server = getServerImpl();
}
return new UnmodifiableHeaders (reqHdrs);
}
return rspHdrs;
}
return uri;
}
return method;
}
return connection.getHttpContext();
}
private boolean isHeadRequest() {
}
public void close () {
if (closed) {
return;
}
closed = true;
/* close the underlying connection if,
* a) the streams not set up yet, no response can be sent, or
* b) if the wrapper output stream is not set up, or
*/
try {
connection.close();
return;
}
connection.close();
return;
}
}
} catch (IOException e) {
connection.close();
}
}
return uis;
}
if (reqContentLen == -1L) {
} else {
}
return uis;
}
return uis_orig;
}
public int getResponseCode () {
return rcode;
}
/* TODO. Change spec to remove restriction below. Filters
* cannot work with this restriction
*
* if (!sentHeaders) {
* throw new IllegalStateException ("headers not sent");
* }
*/
}
return uos;
}
/* returns the place holder stream, which is the stream
* returned from the 1st call to getResponseBody()
* The "real" ouputstream is then placed inside this
*/
return uos_orig;
}
throws IOException
{
if (sentHeaders) {
throw new IOException ("headers already sent");
}
boolean noContentToSend = false; // assume there is content
/* check for response type that is not allowed to send a body */
{
if (contentLen != -1) {
+ ": forcing contentLen = -1";
}
contentLen = -1;
}
if (isHeadRequest()) {
/* HEAD requests should not set a content length by passing it
* through this API, but should instead manually set the required
* headers.*/
if (contentLen >= 0) {
"sendResponseHeaders: being invoked with a content length for a HEAD request";
}
noContentToSend = true;
contentLen = 0;
} else { /* not a HEAD request */
if (contentLen == 0) {
if (http10) {
close = true;
} else {
}
} else {
if (contentLen == -1) {
noContentToSend = true;
contentLen = 0;
}
}
}
this.rspContentLen = contentLen;
sentHeaders = true;
if (noContentToSend) {
WriteFinishedEvent e = new WriteFinishedEvent (this);
closed = true;
}
}
byte[] buf;
buf[i++] = ':';
buf[i++] = ' ';
buf[i++] = '\r';
buf[i++] = '\n';
}
}
}
/**
* convert string to byte[], using rspbuf
* Make sure that at least "extra" bytes are free at end
* of rspbuf. Reallocate rspbuf if not big enough.
* caller must check return value to see if rspbuf moved
*/
}
char c[] = s.toCharArray();
for (int i=0; i<c.length; i++) {
rspbuf[i] = (byte)c[i];
}
return rspbuf;
}
}
int port = s.getLocalPort();
}
}
if (e == null) {
return null;
}
return e.getSession();
}
throw new NullPointerException ("null name parameter");
}
if (attributes == null) {
}
}
throw new NullPointerException ("null name parameter");
}
if (attributes == null) {
}
}
if (i != null) {
uis = i;
}
if (o != null) {
uos = o;
}
}
/**
* PP
*/
return connection;
}
return getHttpContext().getServerImpl();
}
return principal;
}
}
if (t instanceof HttpExchangeImpl) {
return ((HttpExchangeImpl)t).getExchangeImpl();
} else {
assert t instanceof HttpsExchangeImpl;
return ((HttpsExchangeImpl)t).getExchangeImpl();
}
}
}
/**
* An OutputStream which wraps another stream
* which is supplied either at creation time, or sometime later.
* the wrapped stream has been provided, then an IOException will
* be thrown.
*/
}
}
boolean isWrapped () {
}
throw new IOException ("response headers not sent yet");
}
}
checkWrap();
}
checkWrap();
}
checkWrap();
}
checkWrap();
}
checkWrap();
}
}