Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Silent failure with null header value #241

Closed
dylanpyle opened this issue Jan 23, 2017 · 1 comment
Closed

Silent failure with null header value #241

dylanpyle opened this issue Jan 23, 2017 · 1 comment

Comments

@dylanpyle
Copy link

dylanpyle commented Jan 23, 2017

Requests appear to silently fail when a header value is null.

This code works fine:

const headers = {
  'Content-Type': 'multipart/form-data'
};

const files = [
  {
    name: 'image',
    filename: 'image.jpg',
    type: 'image/jpeg',
    data: RNFetchBlob.wrap(filePath)
  }
];

RNFetchBlob.fetch('POST', url, headers, files)
  .then((response) => { console.log('response: ', response); })
  .catch((err) => { console.log('error: ', err); });

This code silently fails, and neither resolves or rejects:

const headers = {
  'Content-Type': 'multipart/form-data',
  Authorization: null
};

const files = [
  {
    name: 'image',
    filename: 'image.jpg',
    type: 'image/jpeg',
    data: RNFetchBlob.wrap(filePath)
  }
];

RNFetchBlob.fetch('POST', url, headers, files)
  .then((response) => { console.log('response: ', response); })
  .catch((err) => { console.log('error: ', err); });

Using

"react-native-fetch-blob": "0.10.2-beta.1",
"react-native": "0.39.2",
@wkh237
Copy link
Owner

wkh237 commented Jan 27, 2017

@dylanpyle , I've noticed this may due to that our native code does not handle empty header value well, I've added some handling in 0.10.2-beta.8 which will substitute null and undefined headers with an empty string. Please try upgrade you package and see if that works.

@wkh237 wkh237 closed this as completed Feb 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants