Ok. So I could figure out the problem.
The Content-Type sent by SemanticMediaWiki contains the string "application/x-www-form-urlencoded", followed by the encoding.
But 4store tests a strict matching of the Content-Type string value against the string "application/x-www-form-urlencoded"
(via the strcasecmp() function).
This is wrong.
Because what you really want to test is that the Content-Type starts with the string "application/x-www-form-urlencoded".
The correct way should be to use the strncasecmp() function in httpd.c.
Instead of:
strcasecmp(form_type, "application/x-www-form-urlencoded")
you should use:
strncasecmp(form_type, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded"))
That change should be done at line 1202, 1291, 1370,
Note: I have no clue how to alter the code on GitHub.
From 9d02d69abb09547880319715684e2cd43b2447aa Mon Sep 17 00:00:00 2001
Date: Thu, 25 Apr 2013 16:48:09 +0200
Subject: [PATCH] Content-type must ***begin with***
"application/x-www-form-urlencoded"
---
src/http/httpd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/http/httpd.c b/src/http/httpd.c
index 02e16b2..00dcd2d 100644
--- a/src/http/httpd.c
+++ b/src/http/httpd.c
@@ -1199,7 +1199,7 @@ static void http_post_request(client_ctxt *ctxt, gchar *url, gchar *protocol)
url_decode(url);
if (!strcmp(url, "/sparql/")) {
char *form_type = just_content_type(ctxt);
- if (!form_type || strcasecmp(form_type, "application/x-www-form-urlencoded")) {
+ if (!form_type || strncasecmp(form_type, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded"))) {
http_error(ctxt, "400 4store only implements application/x-www-form-urlencoded");
http_close(ctxt);
g_free(form_type);
@@ -1288,7 +1288,7 @@ static void http_post_request(client_ctxt *ctxt, gchar *url, gchar *protocol)
} else if (!strcmp(url, "/update/")) {
const char *form_type = g_hash_table_lookup(ctxt->headers, "content-type");
- if (!form_type || strcasecmp(form_type, "application/x-www-form-urlencoded")) {
+ if (!form_type || strncasecmp(form_type, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded"))) {
http_error(ctxt, "400 4store only implements application/x-www-form-urlencoded");
http_close(ctxt);
return;
@@ -1367,7 +1367,7 @@ static void http_post_request(client_ctxt *ctxt, gchar *url, gchar *protocol)
} else if (!strcmp(url, "/data/")) {
char *form_type = just_content_type(ctxt);
- if (!form_type || strcasecmp(form_type, "application/x-www-form-urlencoded")) {
+ if (!form_type || strncasecmp(form_type, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded"))) {
http_error(ctxt, "400 4store only implements application/x-www-form-urlencoded");
http_close(ctxt);
g_free(form_type);
--
1.7.10.4