Java Code Examples for io.vertx.core.buffer.Buffer#appendBuffer()
The following examples show how to use
io.vertx.core.buffer.Buffer#appendBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PipePayloadParser.java From jetlinks-community with Apache License 2.0 | 6 votes |
public PipePayloadParser complete() { currentPipe.set(0); if (recordParser != null) { firstInit.accept(recordParser); } if (!this.result.isEmpty()) { Buffer buffer = Buffer.buffer(); for (Buffer buf : this.result) { buffer.appendBuffer(buf); } this.result.clear(); sink.next(buffer); } return this; }
Example 2
Source File: Frame.java From vertx-stomp with Apache License 2.0 | 5 votes |
/** * This method does not enforce the trailing line option. It should not be used directly, except for the PING frame. * * @return a {@link Buffer} containing the STOMP frame. It follows strictly the STOMP specification (including * header encoding). */ public Buffer toBuffer() { Buffer buffer = Buffer.buffer(command.name() + "\n"); for (Map.Entry<String, String> entry : headers.entrySet()) { buffer.appendString(encode(entry.getKey()) + ":" + encode(entry.getValue()) + "\n"); } buffer.appendString("\n"); if (body != null) { buffer.appendBuffer(body); } buffer.appendString(FrameParser.NULL); return buffer; }
Example 3
Source File: SharedDataSessionImpl.java From vertx-web with Apache License 2.0 | 5 votes |
@Override public void writeToBuffer(Buffer buff) { byte[] bytes = id().getBytes(UTF8); buff.appendInt(bytes.length).appendBytes(bytes); buff.appendLong(timeout()); buff.appendLong(lastAccessed()); buff.appendInt(version()); // use cache Buffer dataBuf = writeDataToBuffer(); buff.appendBuffer(dataBuf); }
Example 4
Source File: BodyHandlerTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Test public void testFileUploadFileRemovalOnClientClosesConnection() throws Exception { String uploadsDirectory = tempUploads.newFolder().getPath(); router.clear(); router.route().handler(BodyHandler.create() .setUploadsDirectory(uploadsDirectory)); assertEquals(0, vertx.fileSystem().readDirBlocking(uploadsDirectory).size()); io.vertx.core.http.HttpClientRequest req = client.request(HttpMethod.POST, "/"); String name = "somename"; String fileName = "somefile.dat"; String contentType = "application/octet-stream"; String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO"; Buffer buffer = Buffer.buffer(); String header = "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + fileName + "\"\r\n" + "Content-Type: " + contentType + "\r\n" + "Content-Transfer-Encoding: binary\r\n" + "\r\n"; buffer.appendString(header); buffer.appendBuffer(TestUtils.randomBuffer(50)); req.headers().set("content-length", String.valueOf(buffer.length() + 50)); //partial upload req.headers().set("content-type", "multipart/form-data; boundary=" + boundary); req.write(buffer); for (int i = 100; i > 0 && vertx.fileSystem().readDirBlocking(uploadsDirectory).size() == 0; i--) { Thread.sleep(100); //wait for upload beginning } assertEquals(1, vertx.fileSystem().readDirBlocking(uploadsDirectory).size()); req.connection().close(); for (int i = 100; i > 0 && vertx.fileSystem().readDirBlocking(uploadsDirectory).size() != 0; i--) { Thread.sleep(100); //wait for upload being deleted } assertEquals(0, vertx.fileSystem().readDirBlocking(uploadsDirectory).size()); }
Example 5
Source File: SockJSHandlerTest.java From vertx-web with Apache License 2.0 | 5 votes |
private Buffer combineReplies(List<Buffer> receivedMessages) { Buffer combinedReply = Buffer.buffer(); for (Buffer receivedMessage : receivedMessages) { combinedReply.appendBuffer(receivedMessage); } return combinedReply; }
Example 6
Source File: ByteBufWrappingBytes.java From incubator-tuweni with Apache License 2.0 | 4 votes |
@Override public void appendTo(Buffer buffer) { buffer.appendBuffer(Buffer.buffer(this.byteBuf)); }
Example 7
Source File: BufferWrappingBytes.java From incubator-tuweni with Apache License 2.0 | 4 votes |
@Override public void appendTo(Buffer buffer) { buffer.appendBuffer(this.buffer); }
Example 8
Source File: JsonMessageCodec.java From festival with Apache License 2.0 | 4 votes |
@Override public void encodeToWire(Buffer buffer, Object o) { buffer.appendBuffer(Json.encodeToBuffer(o)); }
Example 9
Source File: VertxBufferImpl.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void writeToBuffer(Buffer buff) { buff.appendInt(this.length()); buff.appendBuffer(this); }
Example 10
Source File: ByteBufWrappingBytes.java From cava with Apache License 2.0 | 4 votes |
@Override public void appendTo(Buffer buffer) { buffer.appendBuffer(Buffer.buffer(this.byteBuf)); }
Example 11
Source File: BufferWrappingBytes.java From cava with Apache License 2.0 | 4 votes |
@Override public void appendTo(Buffer buffer) { buffer.appendBuffer(this.buffer); }
Example 12
Source File: PersonCodec.java From smallrye-reactive-messaging with Apache License 2.0 | 4 votes |
@Override public void encodeToWire(Buffer buffer, Person person) { buffer.appendBuffer(Json.encodeToBuffer(person)); }
Example 13
Source File: VertxBufferImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public void writeToBuffer(Buffer buff) { buff.appendInt(this.length()); buff.appendBuffer(this); }
Example 14
Source File: DataTypeCodec.java From vertx-sql-client with Apache License 2.0 | 4 votes |
private static Buffer binaryDecodeBYTEA(int index, int len, ByteBuf buff) { Buffer target = Buffer.buffer(len); target.appendBuffer(Buffer.buffer(buff.slice(index, len))); return target; }