Example usage for com.squareup.okhttp MediaType type

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

Introduction

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

Prototype

String type

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

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/*from  w  w w.ja  v a 2s  .  c o  m*/
        log.warn("Received multi-status response without Content-Type, assuming XML");
}