Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images served from Flickr are not served with the correct Response Headers #48

Open
bochap opened this issue Jan 17, 2018 · 0 comments
Open

Comments

@bochap
Copy link

bochap commented Jan 17, 2018

In wittr/server/Server.js. the following block of code that is piping the Flickr Response is not setting the headers.

    this._app.get('/photos/:farm-:server-:id-:secret-:type.jpg', (req, res) => {
      const flickrUrl = `http://farm${req.params.farm}.staticflickr.com/${req.params.server}/${req.params.id}_${req.params.secret}_${imgSizeToFlickrSuffix[req.params.type]}.jpg`;
      const flickrRequest = http.request(flickrUrl, flickrRes => {
        flickrRes.pipe(res);
      });

      flickrRequest.on('error', err => {
        // TODO: use a real flickr image as a fallback
        res.sendFile('imgs/icon.png', {
          root: __dirname + '/../public/'
        });
      });

      flickrRequest.end();
    });

This causes the browser to interpret it as text/plain

screen shot 2018-01-17 at 7 09 58 am

The flickrRequest actually contains headers that can be set on the Express response headers and I was able to get the content-type and content-length to be set on the response.

screen shot 2018-01-17 at 7 27 36 am

I think the fix will be to loop through the flickrRequest headers and set it on the Express Response and I will be happy to submit a PR for it. But I want to check if there is a reason we are not setting the headers in this code.

bochap pushed a commit to bochap/wittr that referenced this issue Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant