@@ -348,6 +348,13 @@ private static String getContentType(URLConnection connection) {
348348 contentType = connection .getRequestProperty ("content-type" );
349349 return contentType ;
350350 }
351+ private static String getAccept (URLConnection connection ) {
352+ String accept = connection .getRequestProperty ("Accept" );
353+ if (accept == null )
354+ // From Android: http://developer.android.com/reference/java/net/URLConnection.html
355+ accept = connection .getRequestProperty ("accept" );
356+ return accept ;
357+ }
351358
352359 public void start () {
353360 // Refer to: http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference
@@ -594,6 +601,7 @@ public void start() {
594601 if (status .getCode () != 0 && status .isSuccessful () == false && connection .getResponseBody () == null ) {
595602 Map <String , Object > result = new HashMap <String , Object >();
596603 result .put ("status" , status .getCode ());
604+ result .put ("error" , status .getHTTPMessage ());
597605 connection .setResponseBody (new Body (result ));
598606 }
599607
@@ -665,10 +673,10 @@ private Status sendResponseHeaders(Status status) {
665673 connection .getResHeader ().add ("Server" , String .format ("Couchbase Lite %s" , getVersionString ()));
666674
667675 // Check for a mismatch between the Accept request header and the response type:
668- String accept = connection . getRequestProperty ( "Accept" );
676+ String accept = getAccept ( connection );
669677 if (accept != null && !"*/*" .equals (accept )) {
670678 String responseType = connection .getBaseContentType ();
671- if (responseType != null && accept .indexOf (responseType ) < 0 ) {
679+ if (responseType != null && responseType .indexOf (accept ) < 0 ) {
672680 Log .e (Log .TAG_ROUTER , "Error 406: Can't satisfy request Accept: %s" , accept );
673681 status = new Status (Status .NOT_ACCEPTABLE );
674682 }
0 commit comments