This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

http request
#2
Try this, your content-length header does not include initial XML line.
Edit: you are missing Host and Connection headers.
Code:
data =
'<?xml version="1.0" encoding="UTF-8"?>\r\n' ..
'<Packet>\r\n' ..
'<Command>getRequest</Command>\r\n' ..
'<AirConditioner>\r\n' ..
'<OpGroup GrNo="1" OnOff="*" Mode="*" ErrorStatus="*"></OpGroup>\r\n' ..
'</AirConditioner>\r\n' ..
'</Packet>'

-- http request  
reqs = 'POST /servlet/MIMEReceiveServlet.asp HTTP/1.1\r\n'..
'Content-Type: text/xml\r\n'..
'Host: ' .. ip .. '\r\n' ..
'Connection: close\r\n' ..
'Content-Length: '.. #data..'\r\n\r\n' ..
data

sock = socket.tcp()
sock:settimeout(70)

res, err = sock:connect(ip, port)
log(res,err)

if res then
  res, err = sock:send(reqs)

  if res then
    log('send OK')
    
    res2, err2 = sock:receive("*a")
    sock:close()

    log(res2,err2)
  else
    log('send failed: ' .. tostring(err))
  end
else
  log('connect failed: ' .. tostring(err))
end
Reply


Messages In This Thread
http request - by Angeles - 21.10.2019, 12:20
RE: http request - by admin - 21.10.2019, 12:56
RE: http request - by Angeles - 21.10.2019, 13:29

Forum Jump: