1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Description: port from request to axios
node-request is deprecated. We port the test to node-axios.
Author: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
Bug-Debian: https://bugs.debian.org/958680
Forwarded: not-needed
Last-Update: 2022-04-08
Index: node-opencv-7.0.0+git20200316.f0a03a4b/examples/face-proxy.js
===================================================================
--- node-opencv-7.0.0+git20200316.f0a03a4b.orig/examples/face-proxy.js
+++ node-opencv-7.0.0+git20200316.f0a03a4b/examples/face-proxy.js
@@ -1,8 +1,29 @@
// Face recognition proxy
var http = require('http'),
- request = require('request'),
+ axios = require('axios'),
+ request = _axionRequest,
cv = require('../lib/opencv');
+function _axionRequest(parameters, f) {
+ if (parameters.method == "GET") {
+ axios.get(parameters.uri, {timeout: parameters.timeout})
+ .then(function (body) {
+ f(null, body.request.res, JSON.stringify(body.data));
+ })
+ .catch(function(err){
+ f(err, null, null);
+ })
+ } else if (parameters.method == "POST") {
+ axios.post(parameters.uri, parameters.formData, {timeout: parameters.timeout})
+ .then(function (body) {
+ f(null, body.request.res, JSON.stringify(body.data));
+ })
+ .catch(function(err){
+ f(err, null, null);
+ })
+ }
+}
+
var server = http.createServer(function(req, resp){
var url = req.url.slice(1);
request({uri:url, encoding:'binary'}, function(err, r, body){
Index: node-opencv-7.0.0+git20200316.f0a03a4b/package.json
===================================================================
--- node-opencv-7.0.0+git20200316.f0a03a4b.orig/package.json
+++ node-opencv-7.0.0+git20200316.f0a03a4b/package.json
@@ -9,7 +9,7 @@
},
"devDependencies": {
"glob": "^5.0.3",
- "request": "^2.88.2",
+ "axios": "^0.21.1",
"tape": "^3.0.0"
},
"license": "MIT",
|