Title basically says it all. If I make an HTTP request in ComputerCraft, how can I get any headers that it returns such as the Location header for 301 redirects, the content length, and so on.
Reading HTTP Response Headers?
Started by TehTotalPwnage, Dec 22 2015 02:42 AM
8 replies to this topic
#1
Posted 22 December 2015 - 02:42 AM
#3
#4
Posted 22 December 2015 - 04:27 AM
In that case, there is no way to get any other response header.
#5
Posted 22 December 2015 - 04:37 AM
I've got a memory that the betas for CC 1.76 can do some extra stuff in this area? The http API isn't something I've put a lot of research into.
#6
Posted 22 December 2015 - 12:32 PM
For content length, just do the following:
f.readAll returns the text on the page you requested.
and "#" return the number of elements in an object.
local f = http.get(url) local length = #f.readAll()
f.readAll returns the text on the page you requested.
and "#" return the number of elements in an object.
#7
Posted 22 December 2015 - 03:30 PM
I'd point out fs.getSize before such awkward workarounds.
#9
Posted 22 December 2015 - 05:00 PM
So it is. Which makes your suggestion even worse, because now the content must be fetched a second time to do anything useful with it. At least suggest saving it to a separate string before finding the length!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












