From: David Woodhouse Date: Thu, 18 Aug 2011 12:07:50 +0000 (+0100) Subject: Work around libsoup violating RFC2616 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=users%2Fdwmw2%2Fews-sync.git Work around libsoup violating RFC2616 --- diff --git a/ews_autodiscover.c b/ews_autodiscover.c index bc1aac2..d123dd0 100644 --- a/ews_autodiscover.c +++ b/ews_autodiscover.c @@ -20,6 +20,19 @@ static void souptest_authenticate(SoupSession *sess, SoupMessage *msg, soup_auth_authenticate (auth, authdata->username, authdata->password); } +static void soap_restarted (SoupMessage *msg, gpointer data) +{ + xmlOutputBuffer *buf = data; + + /* In violation of RFC2616, libsoup will change a POST request to + a GET on receiving a 302 redirect. */ + printf("Working around libsoup bug with redirect\n"); + g_object_set (msg, SOUP_MESSAGE_METHOD, "POST", NULL); + + soup_message_set_request(msg, "text/xml", SOUP_MEMORY_COPY, + (gchar *)buf->buffer->content, + buf->buffer->use); +} int main(int argc, char **argv) { SoupSession *sess; @@ -93,6 +106,8 @@ int main(int argc, char **argv) soup_message_set_request(msg, "application/xml", SOUP_MEMORY_COPY, (gchar *)buf->buffer->content, buf->buffer->use); + + g_signal_connect (msg, "restarted", G_CALLBACK (soap_restarted), buf); status = soup_session_send_message(sess, msg);