mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
add 206 to http code check
This commit is contained in:
@@ -201,7 +201,7 @@ class Nextion : Driver
|
|||||||
self.sendnx("connect")
|
self.sendnx("connect")
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_url(url)
|
def open_url_at(url, pos)
|
||||||
|
|
||||||
import string
|
import string
|
||||||
var host
|
var host
|
||||||
@@ -228,6 +228,7 @@ class Nextion : Driver
|
|||||||
self.tcp.connect(host,port)
|
self.tcp.connect(host,port)
|
||||||
log("FLH: Connected:"+str(self.tcp.connected()),3)
|
log("FLH: Connected:"+str(self.tcp.connected()),3)
|
||||||
var get_req = "GET "+get+" HTTP/1.0\r\n"
|
var get_req = "GET "+get+" HTTP/1.0\r\n"
|
||||||
|
get_req += string.format("Range: bytes=%d-\r\n", pos)
|
||||||
get_req += string.format("HOST: %s:%s\r\n\r\n",host,port)
|
get_req += string.format("HOST: %s:%s\r\n\r\n",host,port)
|
||||||
self.tcp.write(get_req)
|
self.tcp.write(get_req)
|
||||||
var a = self.tcp.available()
|
var a = self.tcp.available()
|
||||||
@@ -256,25 +257,26 @@ class Nextion : Driver
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
#print(headers)
|
#print(headers)
|
||||||
# check http respose for code 200
|
# check http respose for code 200/206
|
||||||
var tag = "200 OK"
|
if string.find(headers,"200 OK")>0 || string.find(headers,"206 Partial Content")>0
|
||||||
i = string.find(headers,tag)
|
log("FLH: HTTP Respose is 200 OK or 206 Partial Content",3)
|
||||||
if (i>0)
|
|
||||||
log("FLH: HTTP Respose is 200 OK",3)
|
|
||||||
else
|
else
|
||||||
log("FLH: HTTP Respose is not 200 OK",3)
|
log("FLH: HTTP Respose is not 200 OK or 206 Partial Content",3)
|
||||||
print(headers)
|
print(headers)
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
# check http respose for content-length
|
# only set flash size if pos is zero
|
||||||
tag = "Content-Length: "
|
if pos == 0
|
||||||
i = string.find(headers,tag)
|
# check http respose for content-length
|
||||||
if (i>0)
|
var tag = "Content-Length: "
|
||||||
var i2 = string.find(headers,"\r\n",i)
|
i = string.find(headers,tag)
|
||||||
var s = headers[i+size(tag)..i2-1]
|
if (i>0)
|
||||||
self.flash_size=int(s)
|
var i2 = string.find(headers,"\r\n",i)
|
||||||
end
|
var s = headers[i+size(tag)..i2-1]
|
||||||
log("FLH: Flash file size: "+str(self.flash_size),3)
|
self.flash_size=int(s)
|
||||||
|
end
|
||||||
|
log("FLH: Flash file size: "+str(self.flash_size),3)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user