Example usage for com.squareup.okhttp MediaType subtype

List of usage examples for com.squareup.okhttp MediaType subtype

Introduction

In this page you can find the example usage for com.squareup.okhttp MediaType subtype.

Prototype

String subtype

To view the source code for com.squareup.okhttp MediaType subtype.

Click Source Link

Usage

From source file:at.bitfire.dav4android.DavResource.java

License:Open Source License

protected void assertMultiStatus(Response response) throws DavException {
    if (response.code() != 207)
        throw new InvalidDavResponseException("Expected 207 Multi-Status");

    if (response.body() == null)
        throw new InvalidDavResponseException("Received multi-status response without body");

    MediaType mediaType = response.body().contentType();
    if (mediaType != null) {
        if (!("application".equals(mediaType.type()) || "text".equals(mediaType.type()))
                || !"xml".equals(mediaType.subtype()))
            throw new InvalidDavResponseException("Received non-XML 207 Multi-Status");
    } else/*ww  w .  j a  v a2s .  c  o m*/
        log.warn("Received multi-status response without Content-Type, assuming XML");
}