protected internal virtual URLConnection SendRequest(string method, string path,
                                                      IDictionary <string, string> headers, object bodyObj)
 {
     try
     {
         Uri           url  = new Uri("cblite://" + path);
         URLConnection conn = (URLConnection)url.OpenConnection();
         conn.SetDoOutput(true);
         conn.SetRequestMethod(method);
         if (headers != null)
         {
             foreach (string header in headers.Keys)
             {
                 conn.SetRequestProperty(header, headers.Get(header));
             }
         }
         IDictionary <string, IList <string> > allProperties = conn.GetRequestProperties();
         if (bodyObj != null)
         {
             conn.SetDoInput(true);
             ByteArrayInputStream bais = new ByteArrayInputStream(mapper.WriteValueAsBytes(bodyObj
                                                                                           ));
             conn.SetRequestInputStream(bais);
         }
         Couchbase.Lite.Router.Router router = new Couchbase.Lite.Router.Router(manager, conn
                                                                                );
         router.Start();
         return(conn);
     }
     catch (UriFormatException)
     {
         Fail();
     }
     catch (IOException)
     {
         Fail();
     }
     return(null);
 }