Skip to content

Commit 3204534

Browse files
committed
WS streaming feature restricted to Grizzly provider for the time being.
1 parent 2faa0d8 commit 3204534

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyWebSocket.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,12 @@ public WebSocket sendMessage(byte[] message) {
4343

4444
@Override
4545
public WebSocket stream(byte[] fragment, boolean last) {
46-
if (fragment != null && fragment.length > 0) {
47-
channel.write(new BinaryWebSocketFrame(last, 0, wrappedBuffer(fragment)));
48-
}
49-
return this;
46+
throw new UnsupportedOperationException("Streaming currently only supported by the Grizzly provider.");
5047
}
5148

5249
@Override
5350
public WebSocket stream(byte[] fragment, int offset, int len, boolean last) {
54-
if (fragment != null && fragment.length > 0) {
55-
channel.write(new BinaryWebSocketFrame(last, 0, wrappedBuffer(fragment, offset, len)));
56-
}
57-
return this;
51+
throw new UnsupportedOperationException("Streaming currently only supported by the Grizzly provider.");
5852
}
5953

6054
@Override
@@ -65,8 +59,7 @@ public WebSocket sendTextMessage(String message) {
6559

6660
@Override
6761
public WebSocket streamText(String fragment, boolean last) {
68-
channel.write(new TextWebSocketFrame(last, 0, fragment));
69-
return this;
62+
throw new UnsupportedOperationException("Streaming currently only supported by the Grizzly provider.");
7063
}
7164

7265
@Override

src/test/java/com/ning/http/client/websocket/ByteMessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void onFragment(byte[] fragment, boolean last) {
200200
assertEquals(text.get(), "ECHOECHO".getBytes());
201201
}
202202

203-
@Test
203+
204204
public void echoFragments() throws Exception {
205205
AsyncHttpClient c = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().build());
206206
final CountDownLatch latch = new CountDownLatch(1);

src/test/java/com/ning/http/client/websocket/TextMessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public void onError(Throwable t) {
312312
assertEquals(text.get(), "ECHOECHO");
313313
}
314314

315-
@Test(timeOut = 60000)
315+
316316
public void echoFragments() throws Throwable {
317317
AsyncHttpClient c = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().build());
318318
final CountDownLatch latch = new CountDownLatch(1);

src/test/java/com/ning/http/client/websocket/grizzly/GrizzlyByteMessageTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.ning.http.client.async.ProviderUtil;
1818
import com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider;
1919
import com.ning.http.client.websocket.ByteMessageTest;
20+
import org.testng.annotations.Test;
2021

2122
public class GrizzlyByteMessageTest extends ByteMessageTest {
2223
@Override
@@ -26,4 +27,10 @@ public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
2627
}
2728
return new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config);
2829
}
30+
31+
@Test(timeOut = 60000)
32+
@Override
33+
public void echoFragments() throws Exception {
34+
super.echoFragments();
35+
}
2936
}

src/test/java/com/ning/http/client/websocket/grizzly/GrizzlyTextMessageTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.ning.http.client.async.ProviderUtil;
1818
import com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider;
1919
import com.ning.http.client.websocket.ByteMessageTest;
20+
import org.testng.annotations.Test;
2021

2122
public class GrizzlyTextMessageTest extends ByteMessageTest {
2223
@Override
@@ -26,4 +27,10 @@ public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
2627
}
2728
return new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config);
2829
}
30+
31+
@Test(timeOut = 60000)
32+
@Override
33+
public void echoFragments() throws Exception {
34+
super.echoFragments(); //To change body of overridden methods use File | Settings | File Templates.
35+
}
2936
}

0 commit comments

Comments
 (0)