How to download a file from a webserver with HL7648

Hi, I am trying to download a file from my webserver with a POST request, but the module becomes unresponsive. Can the following sequence of commands be used to get a file from a webserver?
AT+KTCPCFG=1,0,url.com,80
AT+KTCPCNX=1
AT+KTCPSND=1,SIZE

POST /test HTTP/1.1
Host: foo.example
Content-Type: application/x-www-form-urlencoded
Content-Length: 27

var=filename.txt

\r\n\r\n
+++

AT+KTCPRCV=1,500
AT+KTCPCLOSE=1,1

You should use http GET operation, not POST

Have you tried +khttpget command?

No, I didn’t. Is there an example on file download that I can follow?
Thank you

AT+KHTTPCFG=1,“www.google.com”,80,1
at+khttpget=1,"/index.html",1

Hi, thank you for your response. Do you have the same example with a POST request. My web application will send a file in response to a POST request.

AT+KHTTPHEADER=1
CONNECT
Accept : text/html
Context-Length: 64
OK
AT+KHTTPPOST=1, “/get.cgi”
CONNECT
(…Data send…)
HTTP/1.0 200 OK
Content-Type: text/plain
Context-Length: 37
Your data have been accepted.

OK

Hi,
Thank you for your help again. I send the following commands to the modem:

Sent commnd: ‘AT+KHTTPCFG=1,“web.pythonanywhere.com”,80,1\r’
Rspnse: ‘AT+KHTTPCFG=1,“web.pythonanywhere.com”,80,1\r\r\n’
Rspnse: ‘+KHTTPCFG: 1\r\n’
Rspnse: ‘OK\r\n’
Sent commnd: ‘AT+KHTTPHEADER=1\r’
Rspnse: ‘+KCNX_IND: 1,4,1\r\n’
Rspnse: ‘+KCNX_IND: 1,1,0\r\n’
Rspnse: ‘+KHTTP_IND: 1,1\r\n’
Rspnse: ‘AT+KHTTPHEADER=1\r\r\n’
Rspnse: ‘CONNECT\r\n’

Content-Type: application/x-www-form-urlencoded"
Context-Length: ContentLength

+++

I get no response from the modem after that. Can you help me with the issue?

You mean it stuck in data mode?

Did you send --EOF–Pattern-- to indicate it is end of data pattern?

Btw, why did you send content length for twice?

Hi,
Yes, I don’t get an “OK” from the modem.
Do I need to send “–EOF–Pattern–” as a literal string or a “+++” string to indicate EOF?
ContentLength is a variable that holds a numeric value (22 for example)

You need to send --EOF–Pattern–