joltup / rn-fetch-blob

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

Unexpected char in header #573

Open Drazail opened 4 years ago

Drazail commented 4 years ago

Environment

library version: 0.11.2 react: 16.13.0 react-native: 0.61.5 OS: Android

Description

there is this strange problem we are facing while trying to make a post request on android:

the header key we pass to the JS API is:

'X-MOBILE-APP-VERSION'

however on the native side RNFetchBlob tries to set the header as:

x-mobıle-app-versıonnull

this issue happens only when device's language is set to Turkish and the header is in caps. ( presumably ,depending on the header, other non ASCII languages should face the same problem)

Speculation

seems to be originating from .toLowerCase() in RNFetchBlobReq.java

StackTrace:

Error RNFetchBlob request error: Unexpected char 0x131 at 5 in header name: x-mobıle-app-versıonnull node_modules/rn-fetch-blob/index.js:307:25 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:483:12 value node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:28 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:8 value node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:17 value [native code] value

CodeSample

          const response = await RNFetchBlob
            .config({ timeout: 4000 })
            .fetch('POST', `${URL}`, {
              'Content-Type': 'application/json',
              Accept: 'application/json',
              'X-MOBILE-APP-VERSION': Config.APP_VERSION,
              'X-MOBILE-APP-MARKET': Config.APP_MARKET,
              'User-Agent': await userAgent,
              Authorization: getToken(),
            }, [
              {
                name: 'id', data: id,
              },
            ]);
the following lines seems to be the problem:
 'X-MOBILE-APP-VERSION': Config.APP_VERSION,
 'X-MOBILE-APP-MARKET': Config.APP_MARKET,
ObidosDev commented 3 years ago

Same problem. Good explanation. My user has TR locale and got exact the same error

ulrellik commented 3 years ago

Same here, the 'i' causes problems with another header, but the problem is the same: RNFetchBlob request error: Unexpected char 0x131 at 0 in header name: ıf-modified-sincenull The guy has Android Galaxy A71 with Turkish locale and the app sets the header like this: 'If-Modified-Since' so the capital first 'I' has issues.

eczmustafa commented 2 years ago

same problem with Joplin app.

eczmustafa commented 2 years ago

this project seems to be unmaintained but i made a pull request anyway: https://github.com/joltup/rn-fetch-blob/pull/762

Moon1moon commented 2 years ago

same problem with Joplin app.

Telefonun dilini(uygulamanın değil) bir kereliğine ingilizceye alıp senkronizasyon yapınca sorun çözülüyor. Sonra türkçe yapabilirsiniz. 😬

eczmustafa commented 2 years ago

şimdi denedim. ilk sefer de problem çözülmüş gibi göründü. fakat yeni not ekleyince aynı hatayı verdi: Unexpected char 0x131 at 0 in header name: ıf-none-matchnull heralde microsoft veya google'dan birine teslim olmak zorundayız :(

Moon1moon commented 2 years ago

şimdi denedim. ilk sefer de problem çözülmüş gibi göründü. fakat yeni not ekleyince aynı hatayı verdi: Unexpected char 0x131 at 0 in header name: ıf-none-matchnull heralde microsoft veya google'dan birine teslim olmak zorundayız :(

Şifre ekleyince ya da şifreyi değiştirince yeniden ilk sefer için telefonun dilini ingilizceye çevirip bir kere daha senkronize etmek gerekiyor

Moon1moon commented 2 years ago

şimdi denedim. ilk sefer de problem çözülmüş gibi göründü. fakat yeni not ekleyince aynı hatayı verdi: Unexpected char 0x131 at 0 in header name: ıf-none-matchnull heralde microsoft veya google'dan birine teslim olmak zorundayız :(

Şifre ekleyince ya da şifreyi değiştirince yeniden ilk sefer için telefonun dilini ingilizceye çevirip bir kere daha senkronize etmek gerekiyor

halaei commented 2 years ago

I don't understand Turkish but this issue was fixed in this fork: https://github.com/RonRadtke/react-native-blob-util