Try this:
function kodi2(){
receivedData = "";
socket.onConnect = function() {
write("GET /t/p/original/"+cover+".jpg HTTP/1.0\r\n");
write("HOST: image.tmdb.org\r\n");
write("CONNECTION: close\r\n");
write("\r\n");
};
socket.onData = function() {
receivedData += read();
};
socket.onIOError = function (e) {
widget("output").label = "IOError " + e;
};
socket.onClose = function () {
var imageStartIndex, bitmapData, myImage;
// remove the HTTP header from the received data
imageStartIndex = receivedData.indexOf("\r\n\r\n");
bitmapData = receivedData.substring(imageStartIndex+4);
// make and display the image
myImage = new Image(bitmapData);
widget("MOVIE_COVER").setImage(myImage);
};
socket.connect(image.tmdb.org,80,3000);
scheduleAfter(500,kodi3);
};
Some websites require that the 'Host' HTTP Request header be present.
If you are hitting a site that uses the HTTP 1.1 protocol, it is also good to specify the 'Connection' request header.
If you are interested in learning more about the HTTP protocol, I would recommend not looking at the HTTP RFCs but rather a book by O'Reilly called "Webmaster In A Nutshell".
Last edited by Lyndel McGee on August 6, 2020 17:59.