当前位置: 首页>>代码示例>>Java>>正文


Java Callback.succeeded方法代码示例

本文整理汇总了Java中org.eclipse.jetty.util.Callback.succeeded方法的典型用法代码示例。如果您正苦于以下问题:Java Callback.succeeded方法的具体用法?Java Callback.succeeded怎么用?Java Callback.succeeded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.util.Callback的用法示例。


在下文中一共展示了Callback.succeeded方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResponseContent

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
@Override
protected void onResponseContent(final HttpServletRequest request, final HttpServletResponse response, final Response proxyResponse,
		final byte[] buffer, final int offset, final int length, final Callback callback) {
	final int plainStatus = needPlainPageErrorStatus(request, proxyResponse.getStatus());
	if (plainStatus == 0) {
		super.onResponseContent(request, response, proxyResponse, buffer, offset, length, callback);
	} else {
		try {
			// Standard 404/... page, abort the original response
			final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + plainStatus + ".html");
			dispatcher.forward(getRoot(request), response);
			callback.succeeded();
		} catch (final Exception e) {
			callback.failed(e);
		}
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:18,代码来源:BackendProxyServlet.java

示例2: onData

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
  LOG.info(frame);
  callback.succeeded();
  if (frame.isEndStream()) {
    phaser.arrive();
  }
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:9,代码来源:StreamListener.java

示例3: onResponseContent

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
protected void onResponseContent(HttpServletRequest request, HttpServletResponse response, Response proxyResponse, byte[] buffer, int offset, int length, Callback callback) {
		try {
			// if (_log.isDebugEnabled())
			_log.info("{} proxying content to downstream: {} bytes", getRequestId(request), length);
			// System.err.println("buffer:" + new String(buffer));
			// response.setHeader("version", "1.1");
			// org.eclipse.jetty.server.Request req = (org.eclipse.jetty.server.Request) request;

			// req.setHttpVersion(HttpVersion.HTTP_1_1);
			// req.getHttpVersion().

			// HttpVersion dd;
			// org.eclipse.jetty.server.Response res = (org.eclipse.jetty.server.Response) response;
			// // res.
			// org.eclipse.jetty.server.HttpOutput output = (HttpOutput) response.getOutputStream();
			//
			// HttpConnection conn = (HttpConnection) output.getInterceptor();
			// System.out.println("response.getOutputStream():" + response.getOutputStream().getClass().getName());
			System.err.println("response:" + response.getClass().getName());

			// response.getWriter().write(new String(buffer));
			// response.flushBuffer();
//			response.getOutputStream().write(buffer, offset, length);
			OutputStream out = response.getOutputStream();
			out.write(buffer);
			out.flush();
			callback.succeeded();
		}
		catch (Throwable x) {
			callback.failed(x);
		}
	}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:33,代码来源:ProxyServlet.java

示例4: onResponseContent

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
protected void onResponseContent(HttpServletRequest request, HttpServletResponse response, Response proxyResponse, byte[] buffer, int offset, int length, Callback callback) {
    try {
        if (LOG.isDebugEnabled()) LOG.debug("{} proxying content to downstream: {} bytes", getRequestId(request), length);
        response.getOutputStream().write(buffer, offset, length);
        callback.succeeded();
    } catch (Throwable x) {
        LOG.error("Error:", x);
        callback.failed(x);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:11,代码来源:ProxyServlet.java

示例5: onData

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
    byte[] bytes = new byte[frame.getData().remaining()];
    frame.getData().get(bytes);
    System.out.println("[" + frame.getStreamId() + "] DATA " + new String(bytes));
    callback.succeeded();
    
    if (frame.isEndStream()) {
        completedFuture.complete(null);
    }
}
 
开发者ID:grro,项目名称:http2,代码行数:12,代码来源:PrintingFramesHandler.java

示例6: send

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
@Override
public void send(MetaData.Response info, boolean head,
                 ByteBuffer content, boolean lastContent, Callback callback) {

    if (info != null) {
        this.info = info;
    }

    final int length = content.remaining();
    if (length == 0) {
        callback.succeeded();
        return;
    }

    if (content.hasArray()) {
        final int from = content.arrayOffset() + content.position();
        out.add(HttpData.of(Arrays.copyOfRange(content.array(), from, from + length)));
        content.position(content.position() + length);
    } else {
        final byte[] data = new byte[length];
        content.get(data);
        out.add(HttpData.of(data));
    }

    contentLength += length;
    callback.succeeded();
}
 
开发者ID:line,项目名称:armeria,代码行数:28,代码来源:JettyService.java

示例7: onContent

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
@Override
public void onContent(Response response, ByteBuffer content, Callback callback) {
    emit(new ReactiveResponse.Event(ReactiveResponse.Event.Type.CONTENT, request.getReactiveResponse(), content));
    callback.succeeded();
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:6,代码来源:ResponseEventPublisher.java

示例8: main

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    long startTime = System.nanoTime();

    // Create and start HTTP2Client.
    HTTP2Client client = new HTTP2Client();
    SslContextFactory sslContextFactory = new SslContextFactory(true);
    client.addBean(sslContextFactory);
    client.start();

    // Connect to host.
    String host = "localhost";
    int port = 8443;

    FuturePromise<Session> sessionPromise = new FuturePromise<>();
    client.connect(sslContextFactory, new InetSocketAddress(host, port), new ServerSessionListener.Adapter(), sessionPromise);

    // Obtain the client Session object.
    Session session = sessionPromise.get(5, TimeUnit.SECONDS);

    // Prepare the HTTP request headers.
    HttpFields requestFields = new HttpFields();
    requestFields.put("User-Agent", client.getClass().getName() + "/" + Jetty.VERSION);
    // Prepare the HTTP request object.
    MetaData.Request request = new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + "/"), HttpVersion.HTTP_2, requestFields);
    // Create the HTTP/2 HEADERS frame representing the HTTP request.
    HeadersFrame headersFrame = new HeadersFrame(request, null, true);

    // Prepare the listener to receive the HTTP response frames.
    Stream.Listener responseListener = new Stream.Listener.Adapter()
    {
        @Override
        public void onData(Stream stream, DataFrame frame, Callback callback)
        {
            byte[] bytes = new byte[frame.getData().remaining()];
            frame.getData().get(bytes);
            int duration = (int) TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
            System.out.println("After " + duration + " seconds: " + new String(bytes));
            callback.succeeded();
        }
    };

    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);

    Thread.sleep(TimeUnit.SECONDS.toMillis(20));

    client.stop();
}
 
开发者ID:fstab,项目名称:http2-examples,代码行数:50,代码来源:JettyClientExample.java

示例9: process

import org.eclipse.jetty.util.Callback; //导入方法依赖的package包/类
private void process(ByteBuffer content, Callback callback, boolean finished) throws IOException {
	ContentTransformer transformer = dialog.attribute(CLIENT_TRANSFORMER, strategy::requestTransform);

	boolean committed = dialog.hasAttribute(PROXY_REQUEST_COMMITTED);

	int contentBytes = content.remaining();

	// Skip transformation for empty non-last buffers.
	if (contentBytes == 0 && !finished) {
		callback.succeeded();
		return;
	}

	try {
		transformer.transform(content, finished, buffers);
	} catch (Throwable x) {
		_log.info("Exception while transforming " + transformer, x);
		throw x;
	}

	int newContentBytes = 0;
	int size = buffers.size();
	if (size > 0) {
		CountingCallback counter = new CountingCallback(callback, size);
		for (int i = 0; i < size; ++i) {
			ByteBuffer buffer = buffers.get(i);
			newContentBytes += buffer.remaining();
			provider.offer(buffer, counter);
		}
		buffers.clear();
	}

	if (finished)
		provider.close();

	_log.debug("{} upstream content transformation {} -> {} bytes", dialog.id(), contentBytes, newContentBytes);

	if (!committed && (size > 0 || finished)) {
		dialog.requestHeader(HttpHeader.CONTENT_LENGTH, null);
		dialog.attribute(PROXY_REQUEST_COMMITTED, () -> true);
		dialog.send(new ProxyResponseListener(dialog, strategy));
	}

	if (size == 0)
		callback.succeeded();
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:47,代码来源:AsyncMiddleManHandler.java


注:本文中的org.eclipse.jetty.util.Callback.succeeded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。