|
|
@ -55,12 +55,12 @@ public class PacketEncoder { |
|
|
|
|
|
|
|
public void encodeJsonP(Integer jsonpIndex, Queue<Packet> packets, ByteBuf out, ByteBufAllocator allocator, int limit) throws IOException { |
|
|
|
boolean jsonpMode = jsonpIndex != null; |
|
|
|
|
|
|
|
|
|
|
|
ByteBuf buf = out; |
|
|
|
if (jsonpMode) { |
|
|
|
buf = allocateBuffer(allocator); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
while (true) { |
|
|
|
Packet packet = packets.poll(); |
|
|
@ -81,7 +81,7 @@ public class PacketEncoder { |
|
|
|
buf.writeBytes(toChars(packetSize)); |
|
|
|
buf.writeBytes(B64_DELIMITER); |
|
|
|
buf.writeBytes(packetBuf); |
|
|
|
|
|
|
|
|
|
|
|
i++; |
|
|
|
} |
|
|
|
|
|
|
@ -89,8 +89,9 @@ public class PacketEncoder { |
|
|
|
out.writeBytes(JSONP_HEAD); |
|
|
|
out.writeBytes(toChars(jsonpIndex)); |
|
|
|
out.writeBytes(JSONP_START); |
|
|
|
|
|
|
|
|
|
|
|
String packet = buf.toString(CharsetUtil.UTF_8); |
|
|
|
buf.release(); |
|
|
|
// TODO optimize |
|
|
|
packet = QUOTES_PATTERN.matcher(packet).replaceAll("\\\\\""); |
|
|
|
packet = new String(packet.getBytes(CharsetUtil.UTF_8), CharsetUtil.ISO_8859_1); |
|
|
|