wkh237 / react-native-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.61k stars 1.59k forks source link

Different response headers for same response #584

Open parohy opened 6 years ago

parohy commented 6 years ago

Hello! I run into a strange behavior. I am debugging my app with Charles 4.2. Our backend supports if-modified-since header. I am sending a request with the last-modified date to our image backend. In charless i get status code 304 but when i console.log the status code in app I get 200. I even have content length but according to Charles I do not download any body. When I send the request without is-modified-since I have same headers in Charles and in app.

"react-native-fetch-blob": "0.10.8", "react-native": "0.49.3"

const fetchImage = (url, headers, cached) => (
    RNFetchBlob.config({
        appendExt: 'jpg',
        fileCache: true
    }).fetch('GET', url, headers)
        .then(res => {
            const status = Math.floor(res.info().status);
            //If request fails or not modified return cached path
            if (status !== 200) {
                return cached;
            }
            //If request OK with 200
            const resHead = res.respInfo.headers;
            cacheImage(url, res.path(), resHead['Last-Modified'] || resHead['last-modified']);
            return res.path();
        })
);
marlti7 commented 6 years ago

me too. do you fix it?