Example usage for org.apache.mina.http.api HttpMethod GET

List of usage examples for org.apache.mina.http.api HttpMethod GET

Introduction

In this page you can find the example usage for org.apache.mina.http.api HttpMethod GET.

Prototype

HttpMethod GET

To view the source code for org.apache.mina.http.api HttpMethod GET.

Click Source Link

Usage

From source file:audio.broadcast.icecast.IcecastBroadcastMetadataUpdater.java

License:Open Source License

/**
 * Creates an HTTP GET request to update the metadata on the remote server
 *//*w  w w  .j  a  v a 2s .  co  m*/
private HttpRequest createUpdateRequest(String song) {
    try {
        StringBuilder sb = new StringBuilder();
        sb.append("mode=updinfo");
        sb.append("&mount=").append(URLEncoder.encode(mIcecastConfiguration.getMountPoint(), UTF8));
        sb.append("&charset=UTF%2d8");
        sb.append("&song=").append(URLEncoder.encode(song, UTF8));

        HttpRequestImpl request = new HttpRequestImpl(HttpVersion.HTTP_1_1, HttpMethod.GET, "/admin/metadata",
                sb.toString(), getHTTPHeaders());

        return request;
    } catch (UnsupportedEncodingException e) {
        //This should never happen
        mLog.error("UTF-8 encoding is not supported - can't update song metadata");
    }

    return null;
}

From source file:audio.broadcast.shoutcast.v1.ShoutcastV1BroadcastMetadataUpdater.java

License:Open Source License

/**
 * Creates an HTTP GET request to update the metadata on the remote server
 *//*from w  w  w . j av a  2s  .c  o m*/
private HttpRequest createUpdateRequest(String song) {
    try {
        StringBuilder sb = new StringBuilder();
        sb.append("pass=").append(mShoutcastV1Configuration.getPassword());
        sb.append("&mode=updinfo");
        sb.append("&song=").append(URLEncoder.encode(song, UTF8));

        Map<String, String> headers = new HashMap<>();

        HttpRequestImpl request = new HttpRequestImpl(HttpVersion.HTTP_1_0, HttpMethod.GET, "/admin.cgi",
                sb.toString(), headers);

        return request;
    } catch (UnsupportedEncodingException e) {
        //This should never happen
        mLog.error("UTF-8 encoding is not supported - can't update song metadata");
    }

    return null;
}