Search in sources :

Example 1 with UpnpRequest

use of org.teleal.cling.model.message.UpnpRequest in project openhab1-addons by openhab.

the class StreamClientImpl method sendRequest.

@Override
public StreamResponseMessage sendRequest(StreamRequestMessage requestMessage) {
    final UpnpRequest requestOperation = requestMessage.getOperation();
    log.fine("Preparing HTTP request message with method '" + requestOperation.getHttpMethodName() + "': " + requestMessage);
    try {
        // Create the right HTTP request
        HttpUriRequest httpRequest = createHttpRequest(requestMessage, requestOperation);
        // Set all the headers on the request
        httpRequest.setParams(getRequestParams(requestMessage));
        HeaderUtil.add(httpRequest, requestMessage.getHeaders());
        log.fine("Sending HTTP request: " + httpRequest.getURI());
        return httpClient.execute(httpRequest, createResponseHandler());
    } catch (MethodNotSupportedException ex) {
        log.warning("Request aborted: " + ex.toString());
        return null;
    } catch (ClientProtocolException ex) {
        log.warning("HTTP protocol exception executing request: " + requestMessage);
        log.warning("Cause: " + Exceptions.unwrap(ex));
        return null;
    } catch (IOException ex) {
        // Don't log stacktrace
        log.fine("Client connection was aborted: " + ex.getMessage());
        return null;
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) UpnpRequest(org.teleal.cling.model.message.UpnpRequest) MethodNotSupportedException(org.apache.http.MethodNotSupportedException) IOException(java.io.IOException) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Aggregations

IOException (java.io.IOException)1 MethodNotSupportedException (org.apache.http.MethodNotSupportedException)1 ClientProtocolException (org.apache.http.client.ClientProtocolException)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1 UpnpRequest (org.teleal.cling.model.message.UpnpRequest)1