Working on client-side support.
This commit is contained in:
@@ -30,9 +30,18 @@ import java.util.Iterator;
|
||||
*/
|
||||
public abstract class TransportInputStream extends InputStream {
|
||||
|
||||
private InputStream inputStream;
|
||||
|
||||
protected TransportInputStream() {
|
||||
}
|
||||
|
||||
private InputStream getInputStream() throws IOException {
|
||||
if (inputStream == null) {
|
||||
inputStream = createInputStream();
|
||||
}
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
getInputStream().close();
|
||||
}
|
||||
@@ -81,7 +90,7 @@ public abstract class TransportInputStream extends InputStream {
|
||||
/**
|
||||
* Returns the input stream to read from.
|
||||
*/
|
||||
protected abstract InputStream getInputStream() throws IOException;
|
||||
protected abstract InputStream createInputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an iteration over all the header names this request contains. Returns an empty <code>Iterator</code> if
|
||||
|
||||
@@ -44,7 +44,7 @@ public class HttpServletTransportInputStream extends TransportInputStream {
|
||||
this.httpServletRequest = httpServletRequest;
|
||||
}
|
||||
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
protected InputStream createInputStream() throws IOException {
|
||||
return httpServletRequest.getInputStream();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class StubTransportInputStream extends TransportInputStream {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
protected InputStream createInputStream() throws IOException {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public class HttpServletTransportInputStreamTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testReadInputStream() throws Exception {
|
||||
request.setContent(content);
|
||||
byte[] result = FileCopyUtils.copyToByteArray(tis);
|
||||
assertTrue("Invalid contents", Arrays.equals(content, result));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class HttpUrlConnectionTransportInputStream extends TransportInputStream
|
||||
}
|
||||
}
|
||||
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
protected InputStream createInputStream() throws IOException {
|
||||
return connection.getInputStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class JmsTransportInputStream extends TransportInputStream {
|
||||
this.textMessage = textMessage;
|
||||
}
|
||||
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
protected InputStream createInputStream() throws IOException {
|
||||
try {
|
||||
return new ByteArrayInputStream(textMessage.getText().getBytes("UTF-8"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user