APIdia Launch Partner
Top Fields Constructors Methods
sun.net.httpserver

pack-priv Class ExchangeImpl

Additional top-level class in compilation unit: PlaceholderOutputStream.

extends Object
Class Inheritance
Imports
java.io.*, java.net.*, javax.net.ssl.*, java.util.*, java.util.concurrent.ConcurrentHashMap, java.lang.System.Logger, .System.Logger.Level, java.time.Instant, .ZoneId, java.time.format.DateTimeFormatter, java.util.concurrent.atomic.AtomicBoolean, java.util.stream.Stream, com.sun.net.httpserver.*

Field Summary

Modifier and TypeField and Description
pack-priv final Map<String, Object>
pack-priv boolean
pack-priv boolean
pack-priv HttpConnection
private static final byte[]
private final AtomicBoolean
private final AtomicBoolean
private static final DateTimeFormatter
private static final String
pack-priv boolean
pack-priv String
private static final boolean
pack-priv HttpPrincipal
pack-priv int
pack-priv Request
pack-priv long
pack-priv Headers
pack-priv InputStream
pack-priv OutputStream
private byte[]
pack-priv long
pack-priv Headers
pack-priv boolean
pack-priv ServerImpl
pack-priv Thread
pack-priv InputStream
pack-priv LeftOverInputStream
pack-priv OutputStream
pack-priv PlaceholderOutputStream
pack-priv URI
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
ExchangeImpl(String m, URI u, Request req, long len, HttpConnection connection)

Method Summary

Modifier and TypeMethod and Description
private byte[]
bytes(String s, boolean isKey, int extra)

convert string to byte[], using rspbuf Make sure that at least "extra" bytes are free at end of rspbuf.

public void
pack-priv int

Returns:

the new (or current) value of the exchange count.
endExchange
()

Calls ServerImpl::endExchange if not already called for this exchange.

pack-priv static ExchangeImpl
public Object
pack-priv HttpConnection
public HttpContextImpl
public InetSocketAddress
pack-priv LeftOverInputStream
pack-priv PlaceholderOutputStream
public HttpPrincipal
public String
public InetSocketAddress
public InputStream
public Headers
public String
public URI
public OutputStream
public int
public Headers
pack-priv ServerImpl
public SSLSession
private boolean
pack-priv void
postExchangeFinished(boolean
whether all bytes expected by the client have been writen out to the response body output stream.
writefinished
)

Posts the ExchangeFinished event if not already posted.

public void
sendResponseHeaders(int rCode, long contentLen)

public void
setAttribute(String name, Object value)

pack-priv void
public void
pack-priv void
pack-priv synchronized boolean
writefinished()

When true, writefinished indicates that all bytes expected by the client have been written to the response body outputstream, and that the response body outputstream has been closed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
pack-priv final Map<String, Object> attributes
closeback to summary
pack-priv boolean close
closedback to summary
pack-priv boolean closed
connectionback to summary
pack-priv HttpConnection connection
CRLFback to summary
private static final byte[] CRLF
endedback to summary
private final AtomicBoolean ended
finishedback to summary
private final AtomicBoolean finished
FORMATTERback to summary
private static final DateTimeFormatter FORMATTER
http10back to summary
pack-priv boolean http10
methodback to summary
pack-priv String method
perExchangeAttributesback to summary
private static final boolean perExchangeAttributes
principalback to summary
pack-priv HttpPrincipal principal
rcodeback to summary
pack-priv int rcode
reqback to summary
pack-priv Request req
reqContentLenback to summary
pack-priv long reqContentLen
reqHdrsback to summary
pack-priv Headers reqHdrs
risback to summary
pack-priv InputStream ris
rosback to summary
pack-priv OutputStream ros
rspbufback to summary
private byte[] rspbuf
rspContentLenback to summary
pack-priv long rspContentLen
rspHdrsback to summary
pack-priv Headers rspHdrs
sentHeadersback to summary
pack-priv boolean sentHeaders
serverback to summary
pack-priv ServerImpl server
threadback to summary
pack-priv Thread thread
uisback to summary
pack-priv InputStream uis
uis_origback to summary
pack-priv LeftOverInputStream uis_orig
uosback to summary
pack-priv OutputStream uos
uos_origback to summary
pack-priv PlaceholderOutputStream uos_orig
uriback to summary
pack-priv URI uri
writefinishedback to summary
private boolean writefinished

Constructor Detail

ExchangeImplback to summary
pack-priv ExchangeImpl(String m, URI u, Request req, long len, HttpConnection connection) throws IOException

Method Detail

bytesback to summary
private byte[] bytes(String s, boolean isKey, int extra) throws IOException

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 Header values are supposed to be limited to 7-bit ASCII but 8-bit has to be allowed (for ISO_8859_1). For efficiency we just down cast 16 bit Java chars to byte. We don't allow any character that can't be encoded in 8 bits.

closeback to summary
public void close()
endExchangeback to summary
pack-priv int endExchange()

Calls ServerImpl::endExchange if not already called for this exchange. ServerImpl::endExchange must be called exactly once per exchange, and this method ensures that it is not called more than once for this exchange.

Returns:int

the new (or current) value of the exchange count.

getback to summary
pack-priv static ExchangeImpl get(HttpExchange t)
getAttributeback to summary
public Object getAttribute(String name)
getConnectionback to summary
pack-priv HttpConnection getConnection()

PP

getHttpContextback to summary
public HttpContextImpl getHttpContext()
getLocalAddressback to summary
public InetSocketAddress getLocalAddress()
getOriginalInputStreamback to summary
pack-priv LeftOverInputStream getOriginalInputStream()
getPlaceholderResponseBodyback to summary
pack-priv PlaceholderOutputStream getPlaceholderResponseBody()
getPrincipalback to summary
public HttpPrincipal getPrincipal()
getProtocolback to summary
public String getProtocol()
getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()
getRequestBodyback to summary
public InputStream getRequestBody()
getRequestHeadersback to summary
public Headers getRequestHeaders()
getRequestMethodback to summary
public String getRequestMethod()
getRequestURIback to summary
public URI getRequestURI()
getResponseBodyback to summary
public OutputStream getResponseBody()
getResponseCodeback to summary
public int getResponseCode()
getResponseHeadersback to summary
public Headers getResponseHeaders()
getServerImplback to summary
pack-priv ServerImpl getServerImpl()
getSSLSessionback to summary
public SSLSession getSSLSession()
isHeadRequestback to summary
private boolean isHeadRequest()
postExchangeFinishedback to summary
pack-priv void postExchangeFinished(boolean writefinished)

Posts the ExchangeFinished event if not already posted. If `writefinished` is true, marks the exchange as writefinished() so that the connection can be reused.

Parameters
writefinished:boolean

whether all bytes expected by the client have been writen out to the response body output stream.

sendResponseHeadersback to summary
public void sendResponseHeaders(int rCode, long contentLen) throws IOException
setAttributeback to summary
public void setAttribute(String name, Object value)
setPrincipalback to summary
pack-priv void setPrincipal(HttpPrincipal principal)
setStreamsback to summary
public void setStreams(InputStream i, OutputStream o)
writeback to summary
pack-priv void write(Headers map, OutputStream os) throws IOException
writefinishedback to summary
pack-priv synchronized boolean writefinished()

When true, writefinished indicates that all bytes expected by the client have been written to the response body outputstream, and that the response body outputstream has been closed. When all bytes have also been pulled from the request body input stream, this makes it possible to reuse the connection for the next request.