2
$\begingroup$

I am trying to transmit this string as an HTTP Message BODY

url = "http://localhost:2480/batch/FILMSDB";

scrOK=Import["scrOK.m","Package"];

StringLength[scrOK]
1015

URLFetch[url, "StatusCode", "Method" -> "POST", "BodyData" -> scrOK]
200

scrOK is a batch SQL script that is executed successfully (200) on the OrientDB server

Now I am POSTing a different string, i.e. batch SQL script.

scrFail=Import["scrFail.m","Package"];

StringLength[scrFail]
1156

URLFetch[url, "StatusCode", "Method" -> "POST", "BodyData" -> scrFail]
$Failed

and I am getting the message

URLFetch::invhttp: Server returned nothing (no headers, no data). >>

It is clear that the problem has to do with the Content-Length limit on the server that has been set to 1024 characters. I tried to modify headers but it fails.

URLFetch["http://localhost:2480", "Headers" -> {"Content-Length" -> 1000}]

The value {Content-Length ->2000} specified for the option Headers \ is invalid.

URLFetch["http://localhost:2480", "Headers"][[7]]
{"Content-Length", "1350"}

URLFetch[url, "StatusCode", "Method" -> "POST", "Headers" -> {"Content-Length" -> 1200}, "BodyData" -> scrFail]
$Failed

What is really strange is that I have made the same tests on Google Chrome Postman App. The scrFail is passed and executed successfully. I am copying the curl code snippet

curl -X POST -H "Content-Type: text/plain" -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" -H "Postman-Token: 3f9ab406-1013-4bb1-f07a-c53ef6cc09eb" -d

and then the body (scrFail) follows.....

I cannot draw a final conclusion whether this is a problem with OrientDB or there is a way in Wolfram Language to overcome the Content-Length limit of the server. What do you think, please help.

PS: Someone with higher reputation score should change the tag of the question to urlfetch

$\endgroup$
6
  • $\begingroup$ The content length should reflect the actual length of the body data. If your server has a hard limit of 1024 bytes, then it is expected to fail when sending more content, even if the content length header says something else. Did your test with curl was against the same server? $\endgroup$
    – FJRA
    Commented Jul 20, 2015 at 23:53
  • $\begingroup$ If I try to set the content length of the body data with an option such as "Headers" -> {"Content-Length" -> 1156} I am getting an error message of the type General::erropts: The value {Content-Length->1156} specified for the option Headers is invalid. $\endgroup$ Commented Jul 21, 2015 at 5:51
  • $\begingroup$ I tested successfully scrFail body with Google Chrome Postman against the same server. Postman has an option to generate code snippet in Curl. $\endgroup$ Commented Jul 21, 2015 at 6:01
  • $\begingroup$ What happens if you specify the header as a string: "Headers" -> {"Content-Length" -> "1200"}? $\endgroup$
    – ilian
    Commented Jul 22, 2015 at 18:29
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because this problem is only reproducible in a specific version of OrientDB, which makes it only vaguely related to Mathematica. $\endgroup$
    – C. E.
    Commented Oct 11, 2015 at 21:59

1 Answer 1

2
$\begingroup$

Problem solved in OrientDB community version 2.1 I have tried the POST method with string content of size over 10kB It works, so no need to set the content length.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.