[couchdb-glib] Encode document UIDs when doing HTTP requests
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Encode document UIDs when doing HTTP requests
- Date: Wed, 9 Sep 2009 12:30:48 +0000 (UTC)
commit 32315168a38de8d5923ae884a55e4498781908ac
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Sep 9 14:30:29 2009 +0200
Encode document UIDs when doing HTTP requests
couchdb-glib/couchdb-document.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document.c b/couchdb-glib/couchdb-document.c
index ffef220..064e1a5 100644
--- a/couchdb-glib/couchdb-document.c
+++ b/couchdb-glib/couchdb-document.c
@@ -76,7 +76,7 @@ couchdb_document_get (CouchDB *couchdb,
const char *docid,
GError **error)
{
- char *url;
+ char *url, *encoded_docid;
JsonParser *parser;
CouchDBDocument *document = NULL;
@@ -84,7 +84,8 @@ couchdb_document_get (CouchDB *couchdb,
g_return_val_if_fail (dbname != NULL, NULL);
g_return_val_if_fail (docid != NULL, NULL);
- url = g_strdup_printf ("%s/%s/%s", couchdb->hostname, dbname, docid);
+ encoded_docid = soup_uri_encode (docid, NULL);
+ url = g_strdup_printf ("%s/%s/%s", couchdb->hostname, dbname, encoded_docid);
parser = send_message_and_parse (couchdb, SOUP_METHOD_GET, url, NULL, error);
if (parser) {
document = g_object_new (COUCHDB_TYPE_DOCUMENT, NULL);
@@ -95,6 +96,7 @@ couchdb_document_get (CouchDB *couchdb,
g_object_unref (G_OBJECT (parser));
}
+ g_free (encoded_docid);
g_free (url);
return document;
@@ -116,8 +118,13 @@ couchdb_document_put (CouchDBDocument *document,
id = couchdb_document_get_id (document);
body = couchdb_document_to_string (document);
if (id) {
- url = g_strdup_printf ("%s/%s/%s", document->couchdb->hostname, dbname, id);
+ char *encoded_docid;
+
+ encoded_docid = soup_uri_encode (id, NULL);
+ url = g_strdup_printf ("%s/%s/%s", document->couchdb->hostname, dbname, encoded_docid);
parser = send_message_and_parse (document->couchdb, SOUP_METHOD_PUT, url, body, error);
+
+ g_free (encoded_docid);
} else {
url = g_strdup_printf ("%s/%s/", document->couchdb->hostname, dbname);
parser = send_message_and_parse (document->couchdb, SOUP_METHOD_POST, url, body, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]