HTTP GET 요청에서 retreived 텍스트를 구문 분석해야합니다. NodeMCU에서 루아를 사용하고 있는데 익숙하지 않습니다. 나는 그것을 응답을 가져 오기 위해이 스크립트를lua로 HTTP 응답 본문을 가져 오는 방법은 무엇입니까?
local nStart, nEnd = string.find(c, "\n\n")
if (nEnde == nil) then
nStart, nEnd = string.find(c, "\r\n\r\n")
end
c = string.sub(c,nEnd+1)
print("length: "..string.len(c))
data = mysplit(c, "\n") -- fill the field with filenames
HTTP GET 내가 인쇄 할 때 요청이
GET /lua/node.php?id=4022029&list HTTP/1.1
Host: mydomain.com
Accept: */*
User-Agent: Mozilla/4.0 (compatible; esp8266 Lua;)
과 같은 HTTP 응답을 사용하여 한 번에 그것을 하나 개의 행을 분할하는 스크립트를 사용하고
내가 mydomain.com/lua/node.php?id=4022029를 입력하면이
HTTP/1.1 200 OK
Date: Tue, 28 Nov 2017 01:05:12 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=23p8rtds43pd1662ncm5cjhrl3; path=/
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
처럼 보인다list, 나는 파일 목록을 다른 텍스트로 보았지만이 스크립트는 아무것도 가져 오지 않았다. 시체가없는 것처럼 보입니다. 내가 여기서 무엇을 놓치고 있니? HTTP 데이터 청크 인코딩되지 않은 데이터를 가져 오는 경우
내 스크립트가 작동,하지만 청크 인코딩에서 그것을 가져올 수 없습니다입니다
업데이트.
HTTP가 청크로 인코딩되지 않은 localhost에서 작동하도록했습니다. 해당 서버에서 인코딩을 변경할 수 없으므로 청크 분할 된 상태로 유지됩니다. 그 데이터를 파싱하는 방법을 알아 내야합니다. – emir