View | Details | Raw Unified | Return to bug 44494
Collapse All | Expand All

(-)catalina/src/share/org/apache/catalina/connector/CoyoteReader.java (-1 / +1 lines)
Lines 119-125 Link Here
119
119
120
120
121
    public boolean markSupported() {
121
    public boolean markSupported() {
122
        return true;
122
        return ib.markSupported();
123
    }
123
    }
124
124
125
125
(-)catalina/src/share/org/apache/catalina/connector/InputBuffer.java (-17 / +25 lines)
Lines 227-241 Link Here
227
    }
227
    }
228
228
229
229
230
    public int available()
230
    public int available() {
231
        throws IOException {
231
        int available = 0;
232
        if (state == BYTE_STATE) {
232
        if (state == BYTE_STATE) {
233
            return bb.getLength();
233
            available = bb.getLength();
234
        } else if (state == CHAR_STATE) {
234
        } else if (state == CHAR_STATE) {
235
            return cb.getLength();
235
            available = cb.getLength();
236
        } else {
237
            return 0;
238
        }
236
        }
237
        return available;
239
    }
238
    }
240
239
241
240
Lines 308-328 Link Here
308
        if (!gotEnc)
307
        if (!gotEnc)
309
            setConverter();
308
            setConverter();
310
309
310
        int nRead = 0;
311
        if (bb.getLength() <= 0) {
311
        if (bb.getLength() <= 0) {
312
            int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
312
            nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
313
            if (nRead < 0) {
313
            // Data may be remaining in the buffer of ReadConverter('s super).
314
                return -1;
314
            // So we must try to convert whether nRead is positive or not.
315
            }
316
        }
315
        }
317
318
        if (markPos == -1) {
316
        if (markPos == -1) {
319
            cb.setOffset(0);
317
            cb.setOffset(0);
320
            cb.setEnd(0);
318
            cb.setEnd(0);
321
        }
319
        }
320
321
        if((markPos >= 0) && (cb.getLimit()-cb.getEnd()) <= 0){
322
            // markPos will be reset and the status of cb will be modified
323
            // via cb.flushBuffer(), only if more chars exists.
324
            conv.convert(bb, cb, cb.getLimit());
325
        }else{
326
        conv.convert(bb, cb, cb.getLimit()-cb.getEnd());
327
        }
322
        state = CHAR_STATE;
328
        state = CHAR_STATE;
323
        conv.convert(bb, cb, len);
324
        bb.setOffset(bb.getEnd());
325
329
330
        if((nRead < 0) && (cb.getLength()==0)){
331
            return -1;
332
        }
326
        return cb.getLength();
333
        return cb.getLength();
327
334
328
    }
335
    }
Lines 380-386 Link Here
380
387
381
    public boolean ready()
388
    public boolean ready()
382
        throws IOException {
389
        throws IOException {
383
        return (cb.getLength() > 0);
390
        return (available() > 0);
384
    }
391
    }
385
392
386
393
Lines 391-396 Link Here
391
398
392
    public void mark(int readAheadLimit)
399
    public void mark(int readAheadLimit)
393
        throws IOException {
400
        throws IOException {
401
        if (readAheadLimit < 0){ // See BufferedReader#mark(int) JavaDoc
402
            throw new IllegalArgumentException("readAheadLimit value is negative");
403
        }
394
        if (cb.getLength() <= 0) {
404
        if (cb.getLength() <= 0) {
395
            cb.setOffset(0);
405
            cb.setOffset(0);
396
            cb.setEnd(0);
406
            cb.setEnd(0);
Lines 416-424 Link Here
416
        throws IOException {
426
        throws IOException {
417
        if (state == CHAR_STATE) {
427
        if (state == CHAR_STATE) {
418
            if (markPos < 0) {
428
            if (markPos < 0) {
419
                cb.recycle();
429
                throw new IOException("The mark is not effective");
420
                markPos = -1;
421
                throw new IOException();
422
            } else {
430
            } else {
423
                cb.setOffset(markPos);
431
                cb.setOffset(markPos);
424
            }
432
            }

Return to bug 44494