Java Code Examples for org.eclipse.jetty.io.ByteArrayBuffer

The following examples show how to use org.eclipse.jetty.io.ByteArrayBuffer. These examples are extracted from open source projects. 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 Project: shardingsphere-elasticjob-cloud   Author: apache   File: RestfulTestsUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Send request.
 * @param url the url
 * @param method the method name
 * @param content the content
 * @return the http status code
 * @throws Exception exception when error
 */
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();
    }
}
 
Example #2
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: RestfulServerTest.java    License: Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example #3
Source Project: IoTgo_Android_App   Author: itead   File: HttpFields.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source Project: IoTgo_Android_App   Author: itead   File: HttpFields.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source Project: IoTgo_Android_App   Author: itead   File: HttpFields.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source Project: IoTgo_Android_App   Author: itead   File: HttpFields.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}