Skip to content

Commit 130b48c

Browse files
committed
Working
1 parent 3c45a5c commit 130b48c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/java/io/fusionauth/http/io/ChunkedInputStream.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ private int processChunk(byte[] destination, int offset, int length) throws IOEx
7474
// We need to push back any remaining bytes to the InputStream since we may have read more bytes than we needed.
7575
int leftOver = bufferLength - bufferIndex;
7676
if (leftOver > 0) {
77-
((PushbackInputStream) delegate).push(buffer, bufferIndex, leftOver);
77+
// TODO : Daniel : Review : This doesn't seem like a good idea. It will fail silently, but this is required.
78+
if (delegate instanceof PushbackInputStream pis) {
79+
pis.push(buffer, bufferIndex, leftOver);
80+
}
7881
}
7982

8083
return -1;
@@ -106,7 +109,10 @@ private int processChunk(byte[] destination, int offset, int length) throws IOEx
106109
// We need to push back any remaining bytes to the InputStream since we may have read more bytes than we needed.
107110
int leftOver = bufferLength - bufferIndex;
108111
if (leftOver > 0) {
109-
((PushbackInputStream) delegate).push(buffer, bufferIndex, leftOver);
112+
// TODO : Daniel : Review : This doesn't seem like a good idea. It will fail silently, but this is required.
113+
if (delegate instanceof PushbackInputStream pis) {
114+
pis.push(buffer, bufferIndex, leftOver);
115+
}
110116
}
111117
return -1;
112118
}

src/main/java/io/fusionauth/http/server/io/HTTPInputStream.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ public int read(byte[] buffer, int offset, int length) throws IOException {
157157
if (!request.isChunked()) {
158158
int extraBytes = (int) (read - bytesRemaining);
159159
if (extraBytes > 0) {
160-
// TODO : Daniel : I could set the ref type to PushBackInputStream so I don't have to cast.
161-
((PushbackInputStream) delegate).push(buffer, (int) bytesRemaining, extraBytes);
160+
// TODO : Daniel : Review : This doesn't seem like a good idea. It will fail silently, but this is required.
161+
if (delegate instanceof PushbackInputStream pis) {
162+
pis.push(buffer, (int) bytesRemaining, extraBytes);
163+
}
162164
}
163165
}
164166

@@ -182,7 +184,6 @@ private void commit() {
182184
} else if (request.isChunked()) {
183185
logger.trace("Client indicated it was sending an entity-body in the request. Handling body using chunked encoding.");
184186
delegate = new ChunkedInputStream(delegate, chunkedBufferSize);
185-
186187
if (instrumenter != null) {
187188
instrumenter.chunkedRequest();
188189
}

0 commit comments

Comments
 (0)