} else if(exchange.getRequestContentLength() > 0 && exchange.getRequestContentLength() < maxBufferedSize) { exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) {
private void extractBytes() throws IOException { this.exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) { ByteBuffer buffer = ByteBuffer.wrap(message); exchange.putAttachment(BYTE_BUFFER_KEY, buffer); } },ERROR_CALLBACK); }
public void receiveFullBytesAndProceed(final ActionContext context, final RequestHandler handler) { ActionContext.clearLocal(); hse.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) { body = message; context.saveLocal(); handler.handle(context); } }); }
public void receiveFullBytesAndProceed(final ActionContext context, final RequestHandler handler) { ActionContext.clearLocal(); hse.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) { body = message; context.saveLocal(); handler.handle(context); } }); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { boolean v2 = exchange.getRelativePath().equals("/api/v2/spans"); boolean v1 = !v2 && exchange.getRelativePath().equals("/api/v1/spans"); if (!v2 && !v1) { next.handleRequest(exchange); return; } if (!POST.equals(exchange.getRequestMethod())) { next.handleRequest(exchange); return; } String contentTypeValue = exchange.getRequestHeaders().getFirst(CONTENT_TYPE); boolean json = contentTypeValue == null || contentTypeValue.startsWith("application/json"); boolean thrift = !json && contentTypeValue.startsWith("application/x-thrift"); boolean proto = v2 && !json && contentTypeValue.startsWith("application/x-protobuf"); if (!json && !thrift && !proto) { exchange .setStatusCode(400) .getResponseSender() .send("unsupported content type " + contentTypeValue + "\n"); return; } HttpCollector collector = v2 ? (json ? JSON_V2 : PROTO3) : thrift ? THRIFT : JSON_V1; metrics.incrementMessages(); exchange.getRequestReceiver().receiveFullBytes(collector, errorCallback); }
.addHttpListener(port, "localhost") .setHandler(ex -> { ex.getRequestReceiver().receiveFullBytes((exchange, bytes) -> { try { DefaultRequest request = new DefaultRequest(
} else if(exchange.getRequestContentLength() > 0 && exchange.getRequestContentLength() < maxBufferedSize) { exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) {
} else if(exchange.getRequestContentLength() > 0 && exchange.getRequestContentLength() < maxBufferedSize) { exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() { @Override public void handle(HttpServerExchange exchange, byte[] message) {