sync-request-curl
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"files": [ | ||
@@ -57,12 +57,12 @@ "dist" | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.5.3", | ||
"@types/morgan": "^1.9.4", | ||
"@types/node": "^20.5.0", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "^8.47.0", | ||
"@types/jest": "^29.5.4", | ||
"@types/morgan": "^1.9.5", | ||
"@types/node": "^20.5.9", | ||
"@typescript-eslint/eslint-plugin": "^6.6.0", | ||
"@typescript-eslint/parser": "^6.6.0", | ||
"eslint": "^8.48.0", | ||
"eslint-plugin-jest": "^27.2.3", | ||
"express": "^4.18.2", | ||
"http-errors": "^2.0.0", | ||
"jest": "^29.6.2", | ||
"jest": "^29.6.4", | ||
"jest-dev-server": "^9.0.0", | ||
@@ -73,4 +73,4 @@ "morgan": "^1.10.0", | ||
"ts-node-dev": "^2.0.0", | ||
"typescript": "^5.1.6" | ||
"typescript": "^5.2.2" | ||
} | ||
} |
@@ -45,2 +45,3 @@ <div align="center"> | ||
- [2.4. Response](#24-response) | ||
- [2.5. Errors](#25-Errors) | ||
- [3. License](#3-license) | ||
@@ -128,3 +129,3 @@ - [4. Compatibility](#4-compatibility) | ||
See [sync-request](https://www.npmjs.com/package/sync-request) for the original documentation. All Libcurl Errors will contain a non-zero integer code that can be looked up [here](https://curl.se/libcurl/c/libcurl-errors.html). | ||
See [sync-request](https://www.npmjs.com/package/sync-request) for the original documentation. See the [Errors](#25-errors) section for information on libcurl errors. | ||
@@ -295,6 +296,6 @@ Please note that this library only supports a subset of the original features which are summarised below. | ||
- **`statusCode`** - a number representing the HTTP status code (e.g. `200`, `400`, `401`, `403`) | ||
- **`headers`** - HTTP response headers | ||
- **`body`** - a string or buffer - use `body.toString()` for common use cases in combination with `JSON.parse()` | ||
- **`getBody`** - a function with an optional `encoding` argument that returns the `body` if `encoding` is undefined, otherwise `body.toString(encoding)`. If `statusCode >= 300`, an `Error` is thrown instead. | ||
- **`url`** - the final URL used in the request after all redirections and with the query string parameters appended. | ||
- **`headers`** - HTTP response headers. The keys/properties of the object will always be in lowercase, e.g. `"content-type"` instead of `"Content-Type"` | ||
- **`body`** - a string or buffer - for JSON responses, use `JSON.parse(response.body.toString())` to get the returned data as an object | ||
- **`getBody`** - a function with an optional `encoding` argument that returns the `body` if `encoding` is undefined, otherwise `body.toString(encoding)`. If `statusCode >= 300`, an `Error` is thrown instead | ||
- **`url`** - the final URL used in the request after all redirections are followed, and with the query string parameters appended | ||
@@ -313,2 +314,19 @@ In [src/types.ts](src/types.ts), the `Response` interface is defined as: | ||
### 2.5. Errors | ||
All Libcurl Errors will contain a non-zero integer code that can be looked up here: | ||
- https://curl.se/libcurl/c/libcurl-errors.html | ||
A few common errors are: | ||
1. CURLE_COULDNT_CONNECT (7) | ||
- Failed to connect() to host or proxy. | ||
- **HINT**: This means that the server could not be reached. For local development (e.g. in testing), ensure that your server has started successfully, or that it did not crash while handling a previous request | ||
1. CURLE_URL_MALFORMAT (3) | ||
- The URL was not properly formatted. | ||
- **HINT**: The request was not successful because your input URL is invalid, e.g. missing domain, protocol or port. Try printing out your input URL, or if it is a GET request, access it directly in a browser | ||
1. CURLE_PEER_FAILED_VERIFICATION (60) | ||
- The remote server's SSL certificate or SSH fingerprint was deemed not OK. This error code has been unified with CURLE_SSL_CACERT since 7.62.0. Its previous value was 51 | ||
- **HINT**: See the [Windows](#41-windows) compatibility section for an explanation and potential workaround | ||
## 3. License | ||
@@ -315,0 +333,0 @@ |
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
43728
400