Skip to content

Commit 2636218

Browse files
committed
Fix PerMessageDeflatExtension RFC 7692 number typos
RFC 7692 was often mistyped as RFC 7962. Fix this.
1 parent 0ece865 commit 2636218

2 files changed

Lines changed: 45 additions & 45 deletions

File tree

src/main/java/org/java_websocket/extensions/permessage_deflate/PerMessageDeflateExtension.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void decodeFrame(Framedata inputFrame) throws InvalidDataException {
194194
return;
195195
}
196196

197-
// check the RFC 7962 compression marker RSV1 whether to start decompressing
197+
// check the RFC 7692 compression marker RSV1 whether to start decompressing
198198
if (inputFrame.isRSV1()) {
199199
isDecompressing = true;
200200
}
@@ -211,7 +211,7 @@ public void decodeFrame(Framedata inputFrame) throws InvalidDataException {
211211
decompressedBytes += decompressed.length;
212212
dataFrame.setPayload(ByteBuffer.wrap(decompressed));
213213

214-
// payload is no longer compressed, clear the RFC 7962 compression marker RSV1
214+
// payload is no longer compressed, clear the RFC 7692 compression marker RSV1
215215
if (!(dataFrame instanceof ContinuousFrame)) {
216216
dataFrame.setRSV1(false);
217217
}
@@ -232,7 +232,7 @@ private byte[] decompress(ByteBuffer buffer, boolean isFinal) throws InvalidData
232232
ByteArrayOutputStream decompressed = new ByteArrayOutputStream();
233233
try {
234234
decompress(buffer, decompressed);
235-
// RFC 7962: Append empty deflate block to the tail end of the payload of the message
235+
// RFC 7692: Append empty deflate block to the tail end of the payload of the message
236236
if (isFinal) {
237237
decompress(ByteBuffer.wrap(EMPTY_DEFLATE_BLOCK), decompressed);
238238
}
@@ -296,7 +296,7 @@ public void encodeFrame(Framedata inputFrame) {
296296
compressedBytes += compressed.length;
297297
dataFrame.setPayload(ByteBuffer.wrap(compressed));
298298

299-
// payload is compressed now, set the RFC 7962 compression marker RSV1
299+
// payload is compressed now, set the RFC 7692 compression marker RSV1
300300
if (!(dataFrame instanceof ContinuousFrame)) {
301301
dataFrame.setRSV1(true);
302302
}
@@ -314,7 +314,7 @@ public void encodeFrame(Framedata inputFrame) {
314314
}
315315

316316
private byte[] compress(ByteBuffer buffer, boolean isFinal) {
317-
// RFC 7962: Generate an empty fragment if the buffer for uncompressed data buffer is empty.
317+
// RFC 7692: Generate an empty fragment if the buffer for uncompressed data buffer is empty.
318318
if (!buffer.hasRemaining() && isFinal) {
319319
return EMPTY_UNCOMPRESSED_DEFLATE_BLOCK;
320320
}
@@ -326,7 +326,7 @@ private byte[] compress(ByteBuffer buffer, boolean isFinal) {
326326
buffer.duplicate().get(input);
327327
compressor.setInput(input);
328328
}
329-
// RFC 7962 prefers the compressor output not to have the BFINAL bit set, so instead of calling
329+
// RFC 7692 prefers the compressor output not to have the BFINAL bit set, so instead of calling
330330
// finish(), deflate with NO_FLUSH until the input is exhausted, then deflate with SYNC_FLUSH
331331
// until the output runs dry.
332332
ByteArrayOutputStream compressed = new ByteArrayOutputStream();

src/test/java/org/java_websocket/extensions/PerMessageDeflateExtensionRFC7962Test.java renamed to src/test/java/org/java_websocket/extensions/PerMessageDeflateExtensionRFC7692Test.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
import org.junit.jupiter.api.Test;
4545

4646
/** RFC 7692 WebSocket Per-Message Deflate Extension Tests */
47-
public class PerMessageDeflateExtensionRFC7962Test {
47+
public class PerMessageDeflateExtensionRFC7692Test {
4848
// RFC 7692 Section 7.2.3.1 A Message Compressed Using One Compressed Deflate Block
49-
private static final String RFC_7962_TEST_MESSAGE_TEXT = "Hello";
50-
private static final byte[] RFC_7962_TEST_MESSAGE_COMPRESSED =
49+
private static final String RFC_7692_TEST_MESSAGE_TEXT = "Hello";
50+
private static final byte[] RFC_7692_TEST_MESSAGE_COMPRESSED =
5151
new byte[] {
5252
(byte) 0xc1, 0x07, (byte) 0xf2, 0x48, (byte) 0xcd, (byte) 0xc9, (byte) 0xc9, 0x07, 0x00
5353
};
54-
private static final byte[] RFC_7962_TEST_MESSAGE_FRAGMENTS =
54+
private static final byte[] RFC_7692_TEST_MESSAGE_FRAGMENTS =
5555
new byte[] {
5656
// first frame:
5757
0x41,
@@ -68,12 +68,12 @@ public class PerMessageDeflateExtensionRFC7962Test {
6868
0x00
6969
};
7070
// RFC 7692 Section 7.2.3.2 Sharing LZ77 Sliding Window
71-
private static final byte[] RFC_7962_TEST_PAYLOAD_COMPRESSED =
71+
private static final byte[] RFC_7692_TEST_PAYLOAD_COMPRESSED =
7272
new byte[] {(byte) 0xf2, 0x48, (byte) 0xcd, (byte) 0xc9, (byte) 0xc9, 0x07, 0x00};
73-
private static final byte[] RFC_7962_TEST_PAYLOAD_COMPRESSED_AGAIN =
73+
private static final byte[] RFC_7692_TEST_PAYLOAD_COMPRESSED_AGAIN =
7474
new byte[] {(byte) 0xf2, 0x00, 0x11, 0x00, 0x00};
7575
// RFC 7692 Section 7.2.3.3 DEFLATE Block with No Compression
76-
private static final byte[] RFC_7962_TEST_MESSAGE_NO_COMPRESSION =
76+
private static final byte[] RFC_7692_TEST_MESSAGE_NO_COMPRESSION =
7777
new byte[] {
7878
(byte) 0xc1,
7979
0x0b,
@@ -90,10 +90,10 @@ public class PerMessageDeflateExtensionRFC7962Test {
9090
0x00
9191
};
9292
// RFC 7692 Section 7.2.3.4 DEFLATE Block with "BFINAL" Set to 1
93-
private static final byte[] RFC_7962_TEST_PAYLOAD_COMPRESSED_BFINAL =
93+
private static final byte[] RFC_7692_TEST_PAYLOAD_COMPRESSED_BFINAL =
9494
new byte[] {(byte) 0xf3, 0x48, (byte) 0xcd, (byte) 0xc9, (byte) 0xc9, 0x07, 0x00, 0x00};
9595
// RFC 7692 Section 7.2.3.5 Two DEFLATE Blocks in One Message
96-
private static final byte[] RFC_7962_TEST_PAYLOAD_TWO_DEFLATE_BLOCKS =
96+
private static final byte[] RFC_7692_TEST_PAYLOAD_TWO_DEFLATE_BLOCKS =
9797
new byte[] {
9898
(byte) 0xf2,
9999
0x48,
@@ -110,7 +110,7 @@ public class PerMessageDeflateExtensionRFC7962Test {
110110
0x00
111111
};
112112
// RFC 7692 Section 7.2.3.6 Compressed Empty Fragment
113-
private static final byte[] RFC_7962_TEST_PAYLOAD_COMPRESSED_EMPTY_FRAGMENT = new byte[] {0x00};
113+
private static final byte[] RFC_7692_TEST_PAYLOAD_COMPRESSED_EMPTY_FRAGMENT = new byte[] {0x00};
114114

115115
private PerMessageDeflateExtension extension;
116116
private Draft_6455 draft;
@@ -135,15 +135,15 @@ private void setupDraft() throws InvalidHandshakeException {
135135
}
136136

137137
@Test
138-
public void testRFC7962Section7231MessageCompression() {
139-
Framedata frame = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
138+
public void testRFC7692Section7231MessageCompression() {
139+
Framedata frame = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
140140
byte[] frameBytes = draft.createBinaryFrame(frame).array();
141-
assertArrayEquals(RFC_7962_TEST_MESSAGE_COMPRESSED, frameBytes);
141+
assertArrayEquals(RFC_7692_TEST_MESSAGE_COMPRESSED, frameBytes);
142142
}
143143

144144
@Test
145-
public void testRFC7962Section7231FragmentsDecompression() throws InvalidDataException {
146-
List<Framedata> frames = draft.translateFrame(ByteBuffer.wrap(RFC_7962_TEST_MESSAGE_FRAGMENTS));
145+
public void testRFC7692Section7231FragmentsDecompression() throws InvalidDataException {
146+
List<Framedata> frames = draft.translateFrame(ByteBuffer.wrap(RFC_7692_TEST_MESSAGE_FRAGMENTS));
147147
assertEquals(2, frames.size());
148148
assertInstanceOf(DataFrame.class, frames.get(0));
149149
assertFalse(frames.get(0) instanceof ContinuousFrame);
@@ -156,83 +156,83 @@ public void testRFC7962Section7231FragmentsDecompression() throws InvalidDataExc
156156
assertFalse(frames.get(1).isRSV1());
157157
assertFalse(frames.get(1).isRSV2());
158158
assertFalse(frames.get(1).isRSV3());
159-
assertEquals(RFC_7962_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
159+
assertEquals(RFC_7692_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
160160
}
161161

162162
@Test
163-
public void testRFC7962Section7232CompressionWithNoContextTakeover()
163+
public void testRFC7692Section7232CompressionWithNoContextTakeover()
164164
throws InvalidHandshakeException {
165165
extension.setServerNoContextTakeover(true);
166166
setupDraft();
167-
Framedata frame1 = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
167+
Framedata frame1 = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
168168
extension.encodeFrame(frame1);
169-
assertArrayEquals(RFC_7962_TEST_PAYLOAD_COMPRESSED, getPayload(frame1));
170-
Framedata frame2 = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
169+
assertArrayEquals(RFC_7692_TEST_PAYLOAD_COMPRESSED, getPayload(frame1));
170+
Framedata frame2 = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
171171
extension.encodeFrame(frame2);
172-
assertArrayEquals(RFC_7962_TEST_PAYLOAD_COMPRESSED, getPayload(frame2));
172+
assertArrayEquals(RFC_7692_TEST_PAYLOAD_COMPRESSED, getPayload(frame2));
173173
}
174174

175175
@Test
176-
public void testRFC7962Section7232CompressionWithContextTakeover() {
177-
Framedata frame1 = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
176+
public void testRFC7692Section7232CompressionWithContextTakeover() {
177+
Framedata frame1 = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
178178
extension.encodeFrame(frame1);
179-
assertArrayEquals(RFC_7962_TEST_PAYLOAD_COMPRESSED, getPayload(frame1));
180-
Framedata frame2 = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
179+
assertArrayEquals(RFC_7692_TEST_PAYLOAD_COMPRESSED, getPayload(frame1));
180+
Framedata frame2 = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
181181
extension.encodeFrame(frame2);
182-
assertArrayEquals(RFC_7962_TEST_PAYLOAD_COMPRESSED_AGAIN, getPayload(frame2));
182+
assertArrayEquals(RFC_7692_TEST_PAYLOAD_COMPRESSED_AGAIN, getPayload(frame2));
183183
}
184184

185185
@Test
186-
public void testRFC7962Section7233DeflateBlockWithNoCompression() throws InvalidDataException {
186+
public void testRFC7692Section7233DeflateBlockWithNoCompression() throws InvalidDataException {
187187
List<Framedata> frames =
188-
draft.translateFrame(ByteBuffer.wrap(RFC_7962_TEST_MESSAGE_NO_COMPRESSION));
188+
draft.translateFrame(ByteBuffer.wrap(RFC_7692_TEST_MESSAGE_NO_COMPRESSION));
189189
assertEquals(1, frames.size());
190190
assertInstanceOf(DataFrame.class, frames.get(0));
191191
assertFalse(frames.get(0) instanceof ContinuousFrame);
192192
assertTrue(frames.get(0).isFin());
193193
assertFalse(frames.get(0).isRSV1());
194194
assertFalse(frames.get(0).isRSV2());
195195
assertFalse(frames.get(0).isRSV3());
196-
assertEquals(RFC_7962_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
196+
assertEquals(RFC_7692_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
197197
}
198198

199199
@Test
200-
public void testRFC7962Section7234DeflateBlockWithBFINAL() throws InvalidDataException {
201-
Framedata frame = buildCompressedFrame(RFC_7962_TEST_PAYLOAD_COMPRESSED_BFINAL);
200+
public void testRFC7692Section7234DeflateBlockWithBFINAL() throws InvalidDataException {
201+
Framedata frame = buildCompressedFrame(RFC_7692_TEST_PAYLOAD_COMPRESSED_BFINAL);
202202
extension.decodeFrame(frame);
203203
assertTrue(frame.isFin());
204204
assertFalse(frame.isRSV1());
205205
assertFalse(frame.isRSV2());
206206
assertFalse(frame.isRSV3());
207-
assertEquals(RFC_7962_TEST_MESSAGE_TEXT, framePayloadToString(frame));
207+
assertEquals(RFC_7692_TEST_MESSAGE_TEXT, framePayloadToString(frame));
208208
}
209209

210210
@Test
211-
public void testRFC7962Section7235TwoDeflateBlocksInOneMessage() throws InvalidDataException {
212-
Framedata frame = buildCompressedFrame(RFC_7962_TEST_PAYLOAD_TWO_DEFLATE_BLOCKS);
211+
public void testRFC7692Section7235TwoDeflateBlocksInOneMessage() throws InvalidDataException {
212+
Framedata frame = buildCompressedFrame(RFC_7692_TEST_PAYLOAD_TWO_DEFLATE_BLOCKS);
213213
extension.decodeFrame(frame);
214214
assertTrue(frame.isFin());
215215
assertFalse(frame.isRSV1());
216216
assertFalse(frame.isRSV2());
217217
assertFalse(frame.isRSV3());
218-
assertEquals(RFC_7962_TEST_MESSAGE_TEXT, framePayloadToString(frame));
218+
assertEquals(RFC_7692_TEST_MESSAGE_TEXT, framePayloadToString(frame));
219219
}
220220

221221
@Test
222-
public void testRFC7962Section7236GeneratingAnEmptyFragment() throws InvalidDataException {
223-
DataFrame frame1 = buildMessageFrame(RFC_7962_TEST_MESSAGE_TEXT);
222+
public void testRFC7692Section7236GeneratingAnEmptyFragment() throws InvalidDataException {
223+
DataFrame frame1 = buildMessageFrame(RFC_7692_TEST_MESSAGE_TEXT);
224224
frame1.setFin(false);
225225
DataFrame frame2 = new ContinuousFrame();
226226
frame2.setFin(true);
227227
extension.encodeFrame(frame1);
228228
extension.encodeFrame(frame2);
229-
assertArrayEquals(RFC_7962_TEST_PAYLOAD_COMPRESSED_EMPTY_FRAGMENT, getPayload(frame2));
229+
assertArrayEquals(RFC_7692_TEST_PAYLOAD_COMPRESSED_EMPTY_FRAGMENT, getPayload(frame2));
230230
extension.decodeFrame(frame1);
231231
extension.decodeFrame(frame2);
232232
List<Framedata> frames = new ArrayList<>(2);
233233
frames.add(frame1);
234234
frames.add(frame2);
235-
assertEquals(RFC_7962_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
235+
assertEquals(RFC_7692_TEST_MESSAGE_TEXT, framesPayloadToString(frames));
236236
}
237237

238238
private DataFrame buildMessageFrame(String message) {

0 commit comments

Comments
 (0)