I've been playing around with the REST module for a couple of days, to make a script that can automatically download from dl.free.fr With other websites, the tests all work excellent! but with this particular website I have a problem: the header does not return a content type, and also does not return a chunked response!
The response header is quite empty to be honest: Date: Tue, 10 Oct 2016 14:59:10 GMT Server: Apache/DL [Apr 9 2012 10:05:09] Cache-Control: no-cache Expires: Fri, 29 Oct 1998 10:10:45 GMT Connection: close Content-Type: text/html
Which results in an error in the rest module: (understandable)
readResponseBody: No Content-Length header AND not a chunked response. Assuming no response body.
However, in firefox there is content! meaning the assumption in this case is wrong. Also, some reading learned me that the server is not required to send content-length or chunked data. (even though it would make live easier if it did...)
Is is possible to obtain the HTML of this page, so I can perform the download? I have not yet found a method using the Chilkat manual for REST.
I fixed the REST API so that it will work with the situation you described above. If you need a preRelease build, please let me know the programming language, operating system, and anything else to know the exact build required.
answered Oct 11 '16 at 20:26
The Chilkat Http object will handle it. You can just pass the URL to the Http.Download method if you want to download directly to a file, or you could call Http.QuickGetStr to return the HTML as a string.
I'll see what can be done about the REST object. The big problem with not having a Content-Length or chunked response is that, if the client decides to read until the server closes the connection, it could hang if the server does not close the connection. Assuming the connection will be closed, then all is OKD. If the server sends a "Connection: close" header (and is speaking truthgully), and dl.free.fr does, then no hang should occur when reading until the socket is closed. I'm assuming that's what Chilkat.Http is doing...
answered Oct 11 '16 at 18:31