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


Java ByteArrayBuffer类代码示例

本文整理汇总了Java中org.eclipse.jetty.io.ByteArrayBuffer的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayBuffer类的具体用法?Java ByteArrayBuffer怎么用?Java ByteArrayBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sentRequest

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
public static int sentRequest(final String url, final String method, final String content) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod(method);
        contentExchange.setRequestContentType(MediaType.APPLICATION_JSON);
        contentExchange.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8")));
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseStatus();
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:18,代码来源:RestfulTestsUtil.java

示例2: sentRequest

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
private static ContentExchange sentRequest(final String content) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange result = new ContentExchange();
        result.setMethod("POST");
        result.setRequestContentType(MediaType.APPLICATION_JSON);
        result.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8")));
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        result.setURL(URL);
        httpClient.send(result);
        result.waitForDone();
        return result;
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:18,代码来源:RestfulServerTest.java

示例3: postData

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
public static InvokeResult postData(String url, String params) {
    if (StringUtils.isBlank(url) || StringUtils.isBlank(params)) {
        return InvokeResult.errorResult;
    }
    ContentExchange contentExchange = new ContentExchange();
    contentExchange.setMethod(HttpMethod.POST.getValue());
    contentExchange.setURL(url);
    try {
        AbstractBuffer content = new ByteArrayBuffer(params.getBytes(InvokerMsg.CHARSET_UTF8));
        contentExchange.setRequestContent(content);
        return invoke(contentExchange);
    } catch (UnsupportedEncodingException e) {
        logger.error(e.getMessage(), e);
    }
    return InvokeResult.errorResult;
}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:17,代码来源:JettyHttpClientUtil.java

示例4: putData

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
public static InvokeResult putData(String url, String params) {
    if (StringUtils.isBlank(url) || StringUtils.isBlank(params)) {
        return InvokeResult.errorResult;
    }
    ContentExchange contentExchange = new ContentExchange();
    contentExchange.setMethod(HttpMethod.PUT.getValue());
    contentExchange.setURL(url);
    try {
        AbstractBuffer content = new ByteArrayBuffer(params.getBytes(InvokerMsg.CHARSET_UTF8));
        contentExchange.setRequestContent(content);
        return invoke(contentExchange);
    } catch (UnsupportedEncodingException e) {
        logger.error(e.getMessage(), e);
    }
    return InvokeResult.errorResult;
}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:17,代码来源:JettyHttpClientUtil.java

示例5: asyncPost

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Sends an HTTP POST request using the asynchronous client
 * 
 * @param Path
 *            Path of the requested resource
 * @param Args
 *            Arguments for the request
 * @param Callback
 *            Callback to handle the response with
 */
public HttpExchange asyncPost(String path, String args, FritzahaCallback callback) {
	if (!isAuthenticated())
		authenticate();
	HttpExchange postExchange = new FritzahaContentExchange(callback);
	postExchange.setMethod("POST");
	postExchange.setURL(getURL(path));
	try {
		postExchange.setRequestContent(new ByteArrayBuffer(addSID(args).getBytes("UTF-8")));
	} catch (UnsupportedEncodingException e1) {
		logger.error("An encoding error occurred in the POST arguments");
		return null;
	}
	postExchange.setRequestContentType("application/x-www-form-urlencoded;charset=utf-8");
	try {
		asyncclient.send(postExchange);
	} catch (IOException e) {
		logger.error("An I/O error occurred while sending the POST request to " + getURL(path));
		return null;
	}
	return postExchange;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:32,代码来源:FritzahaWebInterface.java

示例6: putDateField

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Sets the value of a date field.
 * 
 * @param name the field name
 * @param date the field date value
 */
public void putDateField(Buffer name, long date)
{
    String d=formatDate(date);
    Buffer v = new ByteArrayBuffer(d);
    put(name, v);
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:13,代码来源:HttpFields.java

示例7: addDateField

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Sets the value of a date field.
 * 
 * @param name the field name
 * @param date the field date value
 */
public void addDateField(String name, long date)
{
    String d=formatDate(date);
    Buffer n = HttpHeaders.CACHE.lookup(name);
    Buffer v = new ByteArrayBuffer(d);
    add(n, v);
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:14,代码来源:HttpFields.java

示例8: sendHttpRequest

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
private void sendHttpRequest(JsonRpcClientRequest rpcRequest) throws IOException {
    // serialize the request
    ObjectNode requestNode = rpcRequest.getRequest();
    byte[] data = getMapper().writeValueAsBytes(requestNode);
    ByteArrayBuffer bytes = new ByteArrayBuffer(data);
    // build the HTTP exchange
    JsonRpcHttpExchange exchange = new JsonRpcHttpExchange(this, rpcRequest);
    exchange.setMethod("POST");
    exchange.setURI(mUri);
    exchange.setRequestContent(bytes);
    exchange.setRequestContentType(mContentType);
    // perform the exchange
    mClient.send(exchange);
}
 
开发者ID:promovicz,项目名称:better-jsonrpc,代码行数:15,代码来源:JsonRpcHttpClient.java

示例9: streamingHandshake

import org.eclipse.jetty.io.ByteArrayBuffer; //导入依赖的package包/类
public GenericContentExchange streamingHandshake(String instance, String sessionId) throws IOException {
    GenericContentExchange exchange = new GenericContentExchange();
    //ContentExchange exchange = new ContentExchange();
    exchange.setMethod("POST");
    exchange.setURL(instance + SfdcConstants.DEFAULT_PUSH_ENDPOINT + SfdcConstants.HANDSHAKE);
    exchange.setRequestHeader("Authorization", "Bearer " + sessionId);
    exchange.setRequestHeader("Content-Type", "application/json");
    AbstractBuffer buffer = new ByteArrayBuffer(SfdcConstants.HANDSHAKE_MESSAGE.getBytes());
    exchange.setRequestContent(buffer);
    send(exchange);
    return exchange;
}
 
开发者ID:AlgeFramework,项目名称:alge-core,代码行数:13,代码来源:JettyAsyncHttpClientImpl.java


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