remove need for Content Type application/json on post
This commit is contained in:
parent
00199df3e2
commit
48d839b9b9
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -18,6 +18,17 @@ exports.get = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, fu
|
||||
});
|
||||
exports.post = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
|
||||
optionsArg.method = 'POST';
|
||||
if (typeof optionsArg.requestBody === 'object'
|
||||
&& (!optionsArg.headers || (!optionsArg.headers['Content-Type']))) {
|
||||
// make sure headers exist
|
||||
if (!optionsArg.headers) {
|
||||
optionsArg.headers = {};
|
||||
}
|
||||
// assign the right Content-Type, leaving all other headers in place
|
||||
Object.assign(optionsArg.headers, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
}
|
||||
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
|
||||
return response;
|
||||
});
|
||||
@ -31,4 +42,4 @@ exports.del = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, fu
|
||||
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
|
||||
return response;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBS0EsaUVBQWdEO0FBRWhELCtEQUFnRDtBQUF2Qyx5Q0FBQSxPQUFPLENBQUE7QUFHTCxRQUFBLEdBQUcsR0FBRyxDQUFPLFNBQWlCLEVBQUUsYUFBOEMsRUFBRTtJQUN6RixVQUFVLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQTtJQUN6QixJQUFJLFFBQVEsR0FBRyxNQUFNLDhCQUFPLENBQUMsU0FBUyxFQUFFLFVBQVUsQ0FBQyxDQUFBO0lBQ25ELE1BQU0sQ0FBQyxRQUFRLENBQUE7QUFDakIsQ0FBQ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BQUcsR0FBRyxDQUFPLFNBQWlCLEVBQUUsYUFBOEMsRUFBRSxFQUFFLEVBQUU7SUFDN0YsVUFBVSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUE7SUFDekIsSUFBSSxRQUFRLEdBQUcsTUFBTSw4QkFBTyxDQUFDLFNBQVMsRUFBRSxVQUFVLENBQUMsQ0FBQTtJQUNuRCxNQUFNLENBQUMsUUFBUSxDQUFBO0FBQ2pCLENBQUMsQ0FBQSxDQUFBO0FBRVUsUUFBQSxHQUFHLEdBQUcsQ0FBTyxTQUFpQixFQUFFLGFBQThDLEVBQUUsRUFBRSxFQUFFO0lBQzdGLFVBQVUsQ0FBQyxNQUFNLEdBQUcsUUFBUSxDQUFBO0lBQzVCLElBQUksUUFBUSxHQUFHLE1BQU0sOEJBQU8sQ0FBQyxTQUFTLEVBQUUsVUFBVSxDQUFDLENBQUE7SUFDbkQsTUFBTSxDQUFDLFFBQVEsQ0FBQTtBQUNqQixDQUFDLENBQUEsQ0FBQSJ9
|
1
dist/smartrequest.plugins.d.ts
vendored
1
dist/smartrequest.plugins.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
import 'typings-global';
|
||||
import * as url from 'url';
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
|
3
dist/smartrequest.plugins.js
vendored
3
dist/smartrequest.plugins.js
vendored
@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const url = require("url");
|
||||
exports.url = url;
|
||||
const http = require("http");
|
||||
@ -9,4 +8,4 @@ const https = require("https");
|
||||
exports.https = https;
|
||||
const q = require("smartq");
|
||||
exports.q = q;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRyZXF1ZXN0LnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHJlcXVlc3QucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQkFBMEI7QUFPeEIsa0JBQUc7QUFOTCw2QkFBNEI7QUFPMUIsb0JBQUk7QUFOTiwrQkFBOEI7QUFPNUIsc0JBQUs7QUFMUCw0QkFBMkI7QUFNekIsY0FBQyJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRyZXF1ZXN0LnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHJlcXVlc3QucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDJCQUEwQjtBQU94QixrQkFBRztBQU5MLDZCQUE0QjtBQU8xQixvQkFBSTtBQU5OLCtCQUE4QjtBQU81QixzQkFBSztBQUxQLDRCQUEyQjtBQU16QixjQUFDIn0=
|
2
dist/smartrequest.request.js
vendored
2
dist/smartrequest.request.js
vendored
@ -83,4 +83,4 @@ exports.request = (domainArg, optionsArg = {}, streamArg = false) => __awaiter(t
|
||||
}
|
||||
return done.promise;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRyZXF1ZXN0LnJlcXVlc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHJlcXVlc3QucmVxdWVzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQ0Esa0RBQWlEO0FBR2pELElBQUksYUFBYSxHQUFHLENBQUMsV0FBVztJQUM5QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQzVCLHVDQUF1QztJQUN2QyxJQUFJLElBQUksR0FBRyxFQUFFLENBQUE7SUFDYixXQUFXLENBQUMsRUFBRSxDQUFDLE1BQU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homepage": "https://gitlab.com/pushrocks/smartrequest#README",
|
||||
"dependencies": {
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.17"
|
||||
"smartq": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tapbundle": "^1.0.14",
|
||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
18
test/test.js
18
test/test.js
@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
const smartchai_1 = require("smartchai");
|
||||
const smartrequest = require("../dist/index");
|
||||
describe('smartrequest', function () {
|
||||
it('should request a html document over https', function () {
|
||||
this.timeout(10000);
|
||||
return smartchai_1.expect(smartrequest.get('https://encrypted.google.com/')).to.eventually.property('body').be.a('string');
|
||||
});
|
||||
it('should request a JSON document over https', function () {
|
||||
return smartchai_1.expect(smartrequest.get('https://jsonplaceholder.typicode.com/posts/1')).to.eventually.property('body').property('id').equal(1);
|
||||
});
|
||||
it('should post a JSON document over http', function () {
|
||||
this.timeout(5000);
|
||||
return smartchai_1.expect(smartrequest.post('http://md5.jsontest.com/?text=example_text')).to.eventually.property('body').property('md5').equal('fa4c6baa0812e5b5c80ed8885e55a8a6');
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQix5Q0FBa0M7QUFFbEMsOENBQTZDO0FBRTdDLFFBQVEsQ0FBQyxjQUFjLEVBQUU7SUFDckIsRUFBRSxDQUFDLDJDQUEyQyxFQUFFO1FBQzVDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsTUFBTSxDQUFDLGtCQUFNLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUNsSCxDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQywyQ0FBMkMsRUFBRTtRQUM1QyxNQUFNLENBQUMsa0JBQU0sQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDLDhDQUE4QyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzFJLENBQUMsQ0FBQyxDQUFBO0lBRUYsRUFBRSxDQUFDLHVDQUF1QyxFQUFFO1FBQ3hDLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDbEIsTUFBTSxDQUFDLGtCQUFNLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyw0Q0FBNEMsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxDQUFDLEtBQUssQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO0lBQzNLLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
@ -2,7 +2,7 @@ import 'typings-test'
|
||||
|
||||
import { tap, expect } from 'tapbundle'
|
||||
|
||||
import * as smartrequest from '../dist/index'
|
||||
import * as smartrequest from '../ts/index'
|
||||
|
||||
tap.test('should request a html document over https', async () => {
|
||||
await expect(
|
||||
|
12
ts/index.ts
12
ts/index.ts
@ -16,6 +16,18 @@ export let get = async (domainArg: string, optionsArg: interfaces.ISmartRequestO
|
||||
|
||||
export let post = async (domainArg: string, optionsArg: interfaces.ISmartRequestOptions = {}) => {
|
||||
optionsArg.method = 'POST'
|
||||
if (
|
||||
typeof optionsArg.requestBody === 'object'
|
||||
&& (!optionsArg.headers || (!optionsArg.headers['Content-Type']))
|
||||
){
|
||||
// make sure headers exist
|
||||
if(!optionsArg.headers) { optionsArg.headers = {} }
|
||||
|
||||
// assign the right Content-Type, leaving all other headers in place
|
||||
Object.assign(optionsArg.headers, {
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
}
|
||||
let response = await request(domainArg, optionsArg)
|
||||
return response
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'typings-global'
|
||||
import * as url from 'url'
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
|
@ -284,7 +284,7 @@ typed-promisify@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853"
|
||||
|
||||
typings-global@*, typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.17:
|
||||
typings-global@*, typings-global@^1.0.14, typings-global@^1.0.16:
|
||||
version "1.0.17"
|
||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.17.tgz#41edc331ccec3168289adc8849e1e255efbe7152"
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user