This commit is contained in:
@@ -112,11 +112,11 @@ public abstract class AsyncConnection implements AutoCloseable {
|
||||
|
||||
public abstract void setWriteTimeoutSeconds(int writeTimeoutSeconds);
|
||||
|
||||
public abstract InputStream newInputStream();
|
||||
public abstract ReadableByteChannel readableByteChannel();
|
||||
|
||||
public abstract void read(CompletionHandler<Integer, ByteBuffer> handler);
|
||||
|
||||
public abstract OutputStream newOutputStream();
|
||||
public abstract WritableByteChannel rritableByteChannel();
|
||||
|
||||
public abstract <A> void write(ByteBuffer src, A attachment, CompletionHandler<Integer, ? super A> handler);
|
||||
|
||||
|
||||
@@ -230,13 +230,55 @@ public class TcpAioAsyncConnection extends AsyncConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InputStream newInputStream() {
|
||||
return Channels.newInputStream(this.channel);
|
||||
public final ReadableByteChannel readableByteChannel() {
|
||||
return new ReadableByteChannel() {
|
||||
@Override
|
||||
public int read(ByteBuffer dst) throws IOException {
|
||||
try {
|
||||
return channel.read(dst).get(readTimeoutSeconds > 0 ? readTimeoutSeconds : 6, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("InfiniteRecursion")
|
||||
public boolean isOpen() {
|
||||
return isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("InfiniteRecursion")
|
||||
public void close() throws IOException {
|
||||
close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OutputStream newOutputStream() {
|
||||
return Channels.newOutputStream(this.channel);
|
||||
public final WritableByteChannel rritableByteChannel() {
|
||||
return new WritableByteChannel() {
|
||||
@Override
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
try {
|
||||
return channel.write(src).get(readTimeoutSeconds > 0 ? readTimeoutSeconds : 6, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("InfiniteRecursion")
|
||||
public boolean isOpen() {
|
||||
return isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("InfiniteRecursion")
|
||||
public void close() throws IOException {
|
||||
close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -142,13 +142,13 @@ public class UdpBioAsyncConnection extends AsyncConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InputStream newInputStream() {
|
||||
return Channels.newInputStream(this.channel);
|
||||
public final ReadableByteChannel readableByteChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OutputStream newOutputStream() {
|
||||
return Channels.newOutputStream(this.channel);
|
||||
public final WritableByteChannel rritableByteChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -581,7 +582,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
@ConvertDisabled
|
||||
public final MultiContext getMultiContext() {
|
||||
return new MultiContext(context.getCharset(), this.getContentType(), this.params,
|
||||
new BufferedInputStream(this.channel.newInputStream(), Math.max(array.size(), 8192)) {
|
||||
new BufferedInputStream(Channels.newInputStream(this.channel.readableByteChannel()), Math.max(array.size(), 8192)) {
|
||||
{
|
||||
array.copyTo(this.buf);
|
||||
this.count = array.size();
|
||||
|
||||
Reference in New Issue
Block a user