sync-request-curl
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -8,3 +8,8 @@ "use strict"; | ||
if (code < 1 || code > 99) { | ||
throw new Error(`CurlError code must be between 1 and 99. Given: ${code}`); | ||
throw new Error(` | ||
CurlError code must be between 1 and 99. Given: ${code}. | ||
Please take a look at the resource below for valid Libcurl errors: | ||
- https://curl.se/libcurl/c/libcurl-errors.html | ||
`); | ||
} | ||
@@ -11,0 +16,0 @@ this.code = code; |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.default = request_1.default; | ||
// CommonJS (CJS) | ||
module.exports = request_1.default; | ||
@@ -13,0 +14,0 @@ module.exports.default = request_1.default; |
@@ -11,3 +11,2 @@ "use strict"; | ||
* @returns {Easy} an initialized libcurl Easy object with default options | ||
* ``` | ||
*/ | ||
@@ -71,3 +70,3 @@ const createCurlObjectWithDefaults = (method, options) => { | ||
} | ||
httpHeaders.push(`Content-Length: ${payload.length}`); | ||
httpHeaders.push(`Content-Length: ${Buffer.byteLength(payload, 'utf-8')}`); | ||
curl.setOpt(node_libcurl_1.Curl.option.POSTFIELDS, payload); | ||
@@ -74,0 +73,0 @@ curl.setOpt(node_libcurl_1.Curl.option.WRITEFUNCTION, (buff, nmemb, size) => { |
@@ -40,9 +40,7 @@ /// <reference types="node" /> | ||
/** | ||
* Checks if a CurlCode is valid and throws a CurlError if it's not. | ||
* Checks CURL code and throws a `CurlError` if it indicates failure. | ||
* | ||
* @param {CurlCode} code - The CurlCode to check. | ||
* @param {HttpVerb} method - The HTTP method used in the request. | ||
* @param {string} url - The URL of the request. | ||
* @param {Options} options - The options used in the request. | ||
* @throws {CurlError} if the CurlCode is not CURLE_OK. | ||
* @param {CurlCode} code - The CURL error code to check. | ||
* @param {RequestInputs} requestInputs - input parameters for the CURL request. | ||
* @throws {CurlError} Throws a `CurlError` if the CURL code indicates failure. | ||
*/ | ||
@@ -49,0 +47,0 @@ export declare const checkValidCurlCode: (code: CurlCode, requestInputs: RequestInputs) => void; |
@@ -67,9 +67,7 @@ "use strict"; | ||
/** | ||
* Checks if a CurlCode is valid and throws a CurlError if it's not. | ||
* Checks CURL code and throws a `CurlError` if it indicates failure. | ||
* | ||
* @param {CurlCode} code - The CurlCode to check. | ||
* @param {HttpVerb} method - The HTTP method used in the request. | ||
* @param {string} url - The URL of the request. | ||
* @param {Options} options - The options used in the request. | ||
* @throws {CurlError} if the CurlCode is not CURLE_OK. | ||
* @param {CurlCode} code - The CURL error code to check. | ||
* @param {RequestInputs} requestInputs - input parameters for the CURL request. | ||
* @throws {CurlError} Throws a `CurlError` if the CURL code indicates failure. | ||
*/ | ||
@@ -107,3 +105,4 @@ const checkValidCurlCode = (code, requestInputs) => { | ||
Use 'res.body' instead of 'res.getBody()' to not have any errors thrown. | ||
The status code (in this case, ${statusCode}) can be checked manually with res.statusCode. | ||
The status code (in this case, ${statusCode}) can be checked manually | ||
with res.statusCode. | ||
`); | ||
@@ -110,0 +109,0 @@ } |
@@ -5,3 +5,8 @@ export class CurlError extends Error { | ||
if (code < 1 || code > 99) { | ||
throw new Error(`CurlError code must be between 1 and 99. Given: ${code}`); | ||
throw new Error(` | ||
CurlError code must be between 1 and 99. Given: ${code}. | ||
Please take a look at the resource below for valid Libcurl errors: | ||
- https://curl.se/libcurl/c/libcurl-errors.html | ||
`); | ||
} | ||
@@ -8,0 +13,0 @@ this.code = code; |
@@ -5,2 +5,3 @@ import request from './request'; | ||
export { CurlError }; | ||
// CommonJS (CJS) | ||
module.exports = request; | ||
@@ -7,0 +8,0 @@ module.exports.default = request; |
@@ -9,3 +9,2 @@ import { Curl, Easy } from 'node-libcurl'; | ||
* @returns {Easy} an initialized libcurl Easy object with default options | ||
* ``` | ||
*/ | ||
@@ -69,3 +68,3 @@ const createCurlObjectWithDefaults = (method, options) => { | ||
} | ||
httpHeaders.push(`Content-Length: ${payload.length}`); | ||
httpHeaders.push(`Content-Length: ${Buffer.byteLength(payload, 'utf-8')}`); | ||
curl.setOpt(Curl.option.POSTFIELDS, payload); | ||
@@ -72,0 +71,0 @@ curl.setOpt(Curl.option.WRITEFUNCTION, (buff, nmemb, size) => { |
@@ -40,9 +40,7 @@ /// <reference types="node" /> | ||
/** | ||
* Checks if a CurlCode is valid and throws a CurlError if it's not. | ||
* Checks CURL code and throws a `CurlError` if it indicates failure. | ||
* | ||
* @param {CurlCode} code - The CurlCode to check. | ||
* @param {HttpVerb} method - The HTTP method used in the request. | ||
* @param {string} url - The URL of the request. | ||
* @param {Options} options - The options used in the request. | ||
* @throws {CurlError} if the CurlCode is not CURLE_OK. | ||
* @param {CurlCode} code - The CURL error code to check. | ||
* @param {RequestInputs} requestInputs - input parameters for the CURL request. | ||
* @throws {CurlError} Throws a `CurlError` if the CURL code indicates failure. | ||
*/ | ||
@@ -49,0 +47,0 @@ export declare const checkValidCurlCode: (code: CurlCode, requestInputs: RequestInputs) => void; |
@@ -61,9 +61,7 @@ import { CurlCode } from 'node-libcurl'; | ||
/** | ||
* Checks if a CurlCode is valid and throws a CurlError if it's not. | ||
* Checks CURL code and throws a `CurlError` if it indicates failure. | ||
* | ||
* @param {CurlCode} code - The CurlCode to check. | ||
* @param {HttpVerb} method - The HTTP method used in the request. | ||
* @param {string} url - The URL of the request. | ||
* @param {Options} options - The options used in the request. | ||
* @throws {CurlError} if the CurlCode is not CURLE_OK. | ||
* @param {CurlCode} code - The CURL error code to check. | ||
* @param {RequestInputs} requestInputs - input parameters for the CURL request. | ||
* @throws {CurlError} Throws a `CurlError` if the CURL code indicates failure. | ||
*/ | ||
@@ -100,3 +98,4 @@ export const checkValidCurlCode = (code, requestInputs) => { | ||
Use 'res.body' instead of 'res.getBody()' to not have any errors thrown. | ||
The status code (in this case, ${statusCode}) can be checked manually with res.statusCode. | ||
The status code (in this case, ${statusCode}) can be checked manually | ||
with res.statusCode. | ||
`); | ||
@@ -103,0 +102,0 @@ } |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"files": [ | ||
@@ -57,8 +57,8 @@ "dist" | ||
"devDependencies": { | ||
"@types/express": "^4.17.18", | ||
"@types/jest": "^29.5.5", | ||
"@types/morgan": "^1.9.6", | ||
"@types/node": "^20.8.3", | ||
"@typescript-eslint/eslint-plugin": "^6.7.4", | ||
"@typescript-eslint/parser": "^6.7.4", | ||
"@types/express": "^4.17.20", | ||
"@types/jest": "^29.5.6", | ||
"@types/morgan": "^1.9.7", | ||
"@types/node": "^20.8.7", | ||
"@typescript-eslint/eslint-plugin": "^6.8.0", | ||
"@typescript-eslint/parser": "^6.8.0", | ||
"eslint": "^8.51.0", | ||
@@ -65,0 +65,0 @@ "eslint-plugin-jest": "^27.4.2", |
@@ -414,3 +414,3 @@ <div align="center"> | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALING S IN THE SOFTWARE. | ||
DEALINGS IN THE SOFTWARE. | ||
``` | ||
@@ -417,0 +417,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62646
703