REST- Cache as the server and the client, problem with PUT method , Length required error
Hi,
Trying to work with REST protocol, using IIS 8, both client and server are Cache servers,
I have the following problem-
When I send a PUT command, I get the following error:
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
Get , Post , Delete - work OK.
This problem does not happen if I use Apache, so it's a IIS problem , not a Cache problem.
Searching for solutions on google, this solution is popular-
To fix this error, add an explicit content length to your request before making the API call.
request.ContentLength = 0;
So - using %Net.HttpRequest , how do I accomplish this? ContentLength is a calculated property .
also, did you guys ran into a similar problem using REST ?
Regards,
Nael Nasereldeen
I have not run into this problem. Also, it appears that Caché already adds the Content-Length header:
Set req.Server = "www.google.com"
Do req.EntityBody.Write("test")
Do req.Put("/", 1)
Yields:
User-Agent: Mozilla/4.0 (compatible; Cache;)
Host: www.google.com
Accept-Encoding: gzip
Content-Length: 4
Content-Type: text/html; charset=UTF-8
I suspect Content-Length isn't the actual issue. I don't have any ideas about what is, though. (Perhaps you should at least check if your Caché sends it.)
Thank you Gertjan!
when I write anything to EntityBody of the request, I don't get the length required error anymore.
I guess it makes sense, when using PUT, there is no point in sending an empty EntityBody.
Regards,
Nael