remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

Sometimes no content, but disable images and it works #13

Closed remy closed 10 years ago

remy commented 12 years ago

Example:

inliner -v https://github.com/remy/inliner/

Needs investigation!

agebrock commented 12 years ago

Same here. Any further ideas ? Or possible way to enable error reporting ?

mccartney commented 10 years ago

I have the same problem with some sites, e.g. http://www.onet.pl (Polish popular news site).

I've debugging the problem for several hours and found out this is happening when some of the images return 302 HTTP error code. The code doesn't handle that properly:

      if (res.statusCode !== 200) {
        inliner.emit('progress', 'get ' + res.statusCode + ' on ' + url);
        body = ''; // ?
      } 

Funny thing is, even the comment // ? indicates unsure approach. For me it's enough to resort to the res.headers['location'], because the site refers to an image with a 302 redirection to a valid image.

The real problem with that code is that branch of processing doesn't return anything and doesn't call the callback(), so simply the method call ends with no followup (callback).