--- addressbook/backends/webdav/e-book-backend-webdav.c-ORIGINAL	2008-12-30 18:47:27.000000000 +0100
+++ addressbook/backends/webdav/e-book-backend-webdav.c	2009-01-02 20:24:42.000000000 +0100
@@ -164,7 +166,7 @@
 	SoupMessage *message;
 	gchar       *uri;
 	gchar       *etag;
-	const char  *new_etag;
+	const char  *new_etag, *redir_uri;
 	char        *request;
 	guint        status;
 	const char  *property;
@@ -215,9 +217,22 @@
 	status   = soup_session_send_message(webdav->priv->session, message);
 	new_etag = soup_message_headers_get(message->response_headers, "ETag");
 
+	/* if the server wishes to rename the URI of the message, it can
+	 * (according to the GroupDAV spec) set a "Location" header with the
+	 * new URI. (This contradicts the HTTP/1.1 spec, but there is no other
+	 * easy way to do this...)
+	 */
+	redir_uri = soup_message_headers_get(message->response_headers, "Location");
+	/* TODO: handle relative URI's!! */
+
 	/* set UID and REV fields */
 	e_contact_set(contact, E_CONTACT_REV, (const gpointer) new_etag);
-	e_contact_set(contact, E_CONTACT_UID, uri);
+	if (redir_uri) {
+		g_warning("Resource URI redirected by server to: %s", redir_uri);
+		e_contact_set(contact, E_CONTACT_UID, (const gpointer) redir_uri);
+	} else {
+		e_contact_set(contact, E_CONTACT_UID, uri);
+	}
 
 	g_object_unref(message);
 	g_free(request);
@@ -288,10 +303,12 @@
 	}
 	/* PUT request didn't return an etag? try downloading to get one */
 	if(e_contact_get_const(contact, E_CONTACT_REV) == NULL) {
+		const char *new_uid;
 		EContact *new_contact;
 
 		g_warning("Server didn't return etag for new address resource");
-		new_contact = download_contact(webdav, uid);
+		new_uid = e_contact_get_const(contact, E_CONTACT_UID);
+		new_contact = download_contact(webdav, new_uid);
 		g_object_unref(contact);
 
 		if (new_contact == NULL) {
