user-agent exclusion

This commit is contained in:
Arndt Brenschede 2018-10-27 21:55:59 +02:00
parent 394eff30fa
commit 9e88f37816
2 changed files with 59 additions and 30 deletions

View file

@ -84,36 +84,24 @@ public class ProfileUploadHandler
{
// Content-Type: text/plain;charset=UTF-8
int numChars = 0;
// Content-Length header is in bytes (!= characters for UTF8),
// but Reader reads characters, so don't know number of characters to read
for(;;)
{
// headers
String line = ir.readLine();
if ( line == null ) break;
// blank line before content after headers
if ( line.length() == 0 )
{
int numChars = 0;
// Content-Length header is in bytes (!= characters for UTF8),
// but Reader reads characters, so don't know number of characters to read
for(;;)
{
// read will block when false, occurs at end of stream rather than -1
if (!ir.ready()) {
try { Thread.sleep(1000); } catch( Exception e ) {}
if ( !ir.ready() ) break;
}
int c = ir.read();
if ( c == -1) break;
bw.write( c );
numChars++;
if (numChars > MAX_LENGTH)
throw new IOException("Maximum number of characters exceeded (" + MAX_LENGTH + ", " + id + ")");
}
break;
// read will block when false, occurs at end of stream rather than -1
if (!ir.ready()) {
try { Thread.sleep(1000); } catch( Exception e ) {}
if ( !ir.ready() ) break;
}
int c = ir.read();
if ( c == -1) break;
bw.write( c );
numChars++;
if (numChars > MAX_LENGTH)
throw new IOException("Maximum number of characters exceeded (" + MAX_LENGTH + ", " + id + ")");
}
}