src/index.js
function nosRequest({method, uri, body = '', headers = {}}) {
    return new Promise((resolve, reject) => {
        request({method, uri, body, headers}, function (err, response, body) {
            if (err) {
                return reject(err);
            }
            if(response.statusCode >= 400) {
                parseString(body)
                    .then(({Error}) =>  {
                        let e = {
                            code: Error.Code.join(''),
                            message: Error.Message.join('')
                        };
                        reject(e);
                    }).catch(reject);


            } else if(body) {

                if(typeof body === 'string' && response.headers['content-type'].toLowerCase() ===  XML_MINE) {
                    parseString(body)
                        .then(json => {
                            resolve(json);
                        })
                        .catch(reject);
                } else {
                    resolve( assign({body:body,url:headers.url}) );
                }
            } else {
                let ret = pick(response.headers, [
                    'content-type',
                    'x-nos-request-id',
                    'etag',
                    'content-range',
                    'last-modified',
                    'content-length']);
                assign( ret,{url:headers.url} );
                resolve(ret);
            }
        });
    })
}
function nosRequest({method, uri, body = '', headers = {}}) {
    return new Promise((resolve, reject) => {
        request({method, uri, body, headers}, function (err, response, body) {
            if (err) {
                return reject(err);
            }
            if(response.statusCode >= 400) {
                parseString(body)
                    .then(({Error}) =>  {
                        let e = {
                            code: Error.Code.join(''),
                            message: Error.Message.join('')
                        };
                        reject(e);
                    }).catch(reject);


            } else if(body) {

                if(typeof body === 'string' && response.headers['content-type'].toLowerCase() ===  XML_MINE) {
                    parseString(body)
                        .then(json => {
                            resolve(json);
                        })
                        .catch(reject);
                } else {
                    resolve( assign({body:body,url:headers.url}) );
                }
            } else {
                let ret = pick(response.headers, [
                    'content-type',
                    'x-nos-request-id',
                    'etag',
                    'content-range',
                    'last-modified',
                    'content-length']);
                assign( ret,{url:headers.url} );
                resolve(ret);
            }
        });
    })
}
wrap request
@param {String} method
@param {String} uri
@param {Buffer|String} [body] data to send
@param {Object} headers