fixed blocking client connection
This commit is contained in:
parent
9b60678fbf
commit
3e104548d5
|
@ -78,7 +78,7 @@ public class BlockingHttpConnection extends AbstractHttpConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate output
|
// Generate output
|
||||||
if (_generator.isCommitted() && !_generator.isComplete())
|
while (_generator.isCommitted() && !_generator.isComplete())
|
||||||
{
|
{
|
||||||
if (_generator.flushBuffer()>0)
|
if (_generator.flushBuffer()>0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -492,6 +492,7 @@ public class HttpExchangeTest
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException
|
public int read() throws IOException
|
||||||
{
|
{
|
||||||
|
// System.err.printf("reading 1 of %d/%d%n",_index,data.length());
|
||||||
if (_index>=data.length())
|
if (_index>=data.length())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -503,13 +504,15 @@ public class HttpExchangeTest
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System.err.printf("read 1%n");
|
||||||
return data.charAt(_index++);
|
return data.charAt(_index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] b, int off, int len) throws IOException
|
public int read(byte[] b, int off, int len) throws IOException
|
||||||
{
|
{
|
||||||
|
// System.err.printf("reading %d of %d/%d%n",len,_index,data.length());
|
||||||
if (_index >= data.length())
|
if (_index >= data.length())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -526,18 +529,17 @@ public class HttpExchangeTest
|
||||||
|
|
||||||
while (l < 5 && _index < data.length() && l < len)
|
while (l < 5 && _index < data.length() && l < len)
|
||||||
b[off + l++] = (byte)data.charAt(_index++);
|
b[off + l++] = (byte)data.charAt(_index++);
|
||||||
|
// System.err.printf("read %d%n",l);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpExchange.setRequestContentSource(content);
|
httpExchange.setRequestContentSource(content);
|
||||||
// httpExchange.setRequestContent(new ByteArrayBuffer(data));
|
|
||||||
|
|
||||||
_httpClient.send(httpExchange);
|
_httpClient.send(httpExchange);
|
||||||
|
|
||||||
int status = httpExchange.waitForDone();
|
int status = httpExchange.waitForDone();
|
||||||
// httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED);
|
|
||||||
String result = httpExchange.getResponseContent();
|
String result = httpExchange.getResponseContent();
|
||||||
assertEquals(HttpExchange.STATUS_COMPLETED,status);
|
assertEquals(HttpExchange.STATUS_COMPLETED,status);
|
||||||
assertEquals(data,result);
|
assertEquals(data,result);
|
||||||
|
|
Loading…
Reference in New Issue