silkimen / cordova-plugin-advanced-http Goto Github PK
View Code? Open in Web Editor NEWCordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
License: MIT License
Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
License: MIT License
When can i pull the version 1.8.1 ?
Hello.
I have problems with ios.
I have the latest version of the plugin - 1.7.1.
When checking the certificate for ios error: "libc++abi.dylib: terminating with uncaught exception of type NSException"
But the Android works well.
Could you help me, please?
Hi guys!
It would be a nice feature to extend the behaviour of the setHeader method to support different headers for all further requests based on the host part of an URL. The URL parameter should be optional to preserve the current behaviour.
Something like:
function setHeader() {
var url = '*';
var header = arguments[0];
var value = arguments[1];
if (arguments.length === 3) {
var url = getHost(arguments[0]); // get the host part of the URL
var header = arguments[1];
var value = arguments[2];
}
this.headers[url][header] = value;
}
What is your opinion on this?
Hi,
I am using the plugin for downloading files from a secured endpoint via HTTP only session cookies. Any requests following the login work and do forward any session cookies set. However, this does not seem to be the case when it comes to file download requests.
Request fails and throws an exception when server tries to set an erroneous cookie.
e.g. http://google.com tries to set a cookie for "domain=google.de".
I have a specific scenario where the API I'm calling redirects me to a different success/failure URL (both with status 200 😭).
It doesn't look like the HTTPResponse object contains the URL.
I'm wondering if it's possible to get this added to the library?
First of all, thanks for developing this handy plugin.
Would it be possible to add the support for the HTTP PATCH request method? It would be great and it would allow interacting with RESTful APIs more easily.
Thanks again.
Hi,
I Got this error when I try to install the plugin in my ionic app
cordova plugin add cordova-plugin-advanced-http --save
✖ Running command - failed!
[ERROR] An error occurred while running cordova plugin add cordova-plugin-advanced-http --save (exit code 1):
Error: Failed to fetch plugin cordova-plugin-advanced-http via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
cp: node_modules/umd-tough-cookie/lib/umd-tough-cookie.js: No such file or directory
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node"
"/Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/.bin/npm" "run" "build"
npm ERR! node v7.1.0
npm ERR! npm v2.15.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `cp node_modules/umd-tough-cookie/lib/umd-tough-cookie.js
www/umd-tough-cookie.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script 'cp
node_modules/umd-tough-cookie/lib/umd-tough-cookie.js www/umd-tough-cookie.js'.
npm ERR! This is most likely a problem with the cordova-plugin-advanced-http package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cp node_modules/umd-tough-cookie/lib/umd-tough-cookie.js www/umd-tough-cookie.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs cordova-plugin-advanced-http
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls cordova-plugin-advanced-http
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!
/Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/cordova-plugin-advanced-http/npm-debug.log
npm ERR! addLocalDirectory Could not pack
/Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/cordova-plugin-advanced-http to
/Users/kevinhuron/.npm/cordova-plugin-advanced-http/1.5.10/package.tgz
npm ERR! addLocal Could not install
/Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/cordova-plugin-advanced-http
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node"
"/Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/.bin/npm" "install"
"cordova-plugin-advanced-http" "--save"
npm ERR! node v7.1.0
npm ERR! npm v2.15.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] prepublish: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepublish script 'npm run build'.
npm ERR! This is most likely a problem with the cordova-plugin-advanced-http package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs cordova-plugin-advanced-http
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls cordova-plugin-advanced-http
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/kevinhuron/Documents/ePressPack/mobile-app-v2/eppMobileV2/node_modules/npm-debug.log
Ionic Info :
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : android 6.1.2 ios 4.3.1
Ionic Framework : ionic-angular 3.6.1
System:
Android SDK Tools : 25.2.5
ios-deploy : 1.9.1
Node : v7.1.0
npm : 2.15.12
OS : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235
Misc:
backend : legacy
I tried ionic cordova plugin add cordova-plugin-advanced-http command : not working
and cordova plugin add cordova-plugin-advanced-http : not working
Thank you very much
HTTP is failing to load and I cant use it. I am getting this error everytime http is called.
2017-09-27 21:39:18.361086-0400 TekIT[7181:4408659] TIC TCP Conn Failed [17:0x1c4169480]: 1:61 Err(61)
2017-09-27 21:39:18.361252-0400 TekIT[7181:4408659] Task <102BC563-64BD-4762-905C-A7242C48722E>.<1> HTTP load failed (error code: -1004 [1:61])
2017-09-27 21:39:18.418646-0400 TekIT[7181:4408747] Task <102BC563-64BD-4762-905C-A7242C48722E>.<1> finished with error - code: -1004
2017-09-27 21:39:25.281009-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 13, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.284177-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 20, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.285926-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 23, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.286046-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 7, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.294724-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 16, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.295923-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 24, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.295988-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 26, 1024 bytes): [57] Socket is not connected
2017-09-27 21:39:25.299818-0400 TekIT[7181:4408747] [] nw_socket_get_input_frames recvmsg(fd 27, 1024 bytes): [57] Socket is not connected
Here is my ionic info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
System:
ios-deploy : 1.9.2
Node : v6.11.2
npm : 3.10.10
OS : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235
Misc:
backend : legacy
Not sure whats going on
Hello,
I am trying to use this plugin on a ionic project. I installed it the way the ionic native doc told me to which is:
$ ionic cordova plugin add cordova-plugin-advanced-http
$ npm install --save @ionic-native/http
Then I used it as follow in my provider:
constructor( @Inject(EnvVariables) public envVariables, public correspondanceProvider: CorrespondanceProvider, public http1: HTTP, private platform:Platform) {
this.platform.ready().then(
() => {
this.http1.validateDomainName(false);
}
);
}
But as soon as my provider is called I get the error:
2017-08-30 17:03:26.520184+0200 MyApp WARN: Native: tried calling HTTP.post, but the HTTP plugin is not installed.
2017-08-30 17:03:26.520338+0200 MyApp WARN: Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'
But I have:
cordova plugin ls
✔ Running command - done!
cordova-plugin-advanced-http 1.5.9 "Advanced HTTP plugin"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-screen-orientation 2.0.1 "Screen Orientation"
cordova-plugin-secure-storage 2.6.8 "SecureStorage"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
es6-promise-plugin 4.1.0 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"
Is there another way to install the plugin or am I doing something wrong?
Thanks
Ionic info:
cli packages:
@ionic/cli-utils : 1.6.0 (/Users/jde/Documents/Fork/PRI1701/appliPrintemps/node_modules/ionic/node_modules/@ionic/cli-utils)
ionic (Ionic CLI) : 3.6.0 (/Users/jde/Documents/Fork/PRI1701/appliPrintemps/node_modules/ionic)
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.0.2
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : android 6.2.3 browser 4.1.0 ios 4.4.0
Ionic Framework : ionic-angular 3.5.3
System:
Node : v6.11.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
npm : 3.10.10
On iOS generic errors are returned with error code -1 whereas on Android it's 500. I think it should be -1 for both platforms, because 500 is confusing as it is a valid HTTP error code.
After execution of UploadFile method it returns only 'headers' and 'status' keys. File has been uploaded but app don't receive 'data' key with data from server.
code example:
let seq = this.http.uploadFile(this.url + '/' + endpoint, {}, {}, file_uri, "photo");
seq
.then(response => {
console.log("Response:", response);
)
.catch(err => {});
response log:
Object
headers: Object
connection: "keep-alive"
content-encoding: "gzip"
content-type: "application/json; charset=utf-8"
date: "Fri, 06 Oct 2017 21:23:37 GMT"
server: "nginx/1.2.7"
strict-transport-security: "max-age=15552000"
transfer-encoding: "Identity"
vary: "Authorization, Cookie"
status: 200
Same server but uploading with cordova-plugin-file-transfer. Response data exists in response object:
const fileTransfer: TransferObject = this.transfer.create();
let transferOptions: FileUploadOptions = {
fileKey: 'photo',
fileName: file_uri.substr(file_uri.lastIndexOf('/') + 1)
}
fileTransfer.upload(file_uri, this.url + '/photo/', transferOptions).then(data => {
let res = JSON.parse(data.response);
if (res.success) {
this.setProfilePhoto(res.photo);
}
}, err => {});
Hi,
First of all SSL Pining is working as expected but for the first time like we add certificate and run the application, it works but if we remove certificate and re-run the app than it again works and get the success response. Ideally it shouldn't work as i have removed the certificate file from assets folder.
On trying to install latest version with this command
cordova plugin add [email protected] --save
we get this error
[ERROR] An error occurred while running cordova plugin add [email protected] --save (exit code 1):
Installing "cordova-plugin-advanced-http" for android
Installing "cordova-plugin-file" for android
Installing "cordova-plugin-compat" for android
ANDROID_HOME=/home/abc/software/android/sdk
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_121
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use
Task.doLast(Action) instead.
at build_hglad901zbfl7zbg5bgl3vk5.run(/home/abc/tmp/ionic-3.8.1/platforms/android/build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please
use TaskInputs.file(Object).skipWhenEmpty() instead.
:clean
:CordovaLib:clean
BUILD SUCCESSFUL
Total time: 0.9 secs
The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if
your application needs any changes in its config.xml.
If this is a new application no changes are required.
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may
need to add:
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-advanced-http': CordovaError: Uh oh!
"/home/abc/tmp/ionic-3.8.1/plugins/cordova-plugin-advanced-http/src/android/com/synconset/cordovahttp/CordovaHttp.java"
not found!
at copyFile (/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/lib/pluginHandlers.js:219:36)
at copyNewFile (/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/lib/pluginHandlers.js:250:5)
at install (/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/lib/pluginHandlers.js:43:17)
at Object.process
(/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/cordova-common/src/ActionStack.js:56:25)
at PluginManager.doOperation
(/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/cordova-common/src/PluginManager.js:117:20)
at PluginManager.addPlugin
(/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/cordova-common/src/PluginManager.js:147:17)
at /home/abc/tmp/ionic-3.8.1/platforms/android/cordova/Api.js:254:18
at _fulfilled (/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done
(/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch
(/home/abc/tmp/ionic-3.8.1/platforms/android/cordova/node_modules/q/q.js:816:13)
Error: Uh oh!
"/home/abc/tmp/ionic-3.8.1/plugins/cordova-plugin-advanced-http/src/android/com/synconset/cordovahttp/CordovaHttp.java"
not found!
With version before which is 1.3.7 anything is working without error
I found an error on the cookie handler!
in cookie-handler.js on the splitCookieString function you should check also wor 'Expires=' with upper "E", some service use this.
so something like that
if (cookieParts[i].substr(-11, 8) === 'expires=' || 'Expires=') {
Sorry for that, but I'm not good in making a pull request and it takes a lot of time for me, do you think you can do this?
The getMatchingHostHeaders
method determines the headers for a URL based on the domain and port, but the setHeader
method sets the header based on the domain without the port.
I run the code
cordova.plugin.http.clearCookies();
However the cookie still exists.
The server still get the cookie so I failed to achieve my function.
also,the setCookie function went with errors.
How can I fully control my cookies?
The plugin works good with session cookies, they are forwarded on every http or https call as expected.
But In our project we use also WebSockets, and we need to forward the cookies get from http/s call with your plugin to the WebSocket call.
If we use native http calls and native websockets calls this is working out of the box, I'm not sure if this should also work in your case, but I don't think so. Also I don't know how you are handling the cookie store and how we can extract the cookie.
So what do you think about it, can we do this with your plugin, should it work, or do you think you can adapt the plugin working for that?
Hello. I would like to ask how handle session cookies. Cookies are not send to server.
Cookie header of reaponse is 'set-cookie': [ 'JSESSIONID=dhs-srcyD+z-w6mjCNKS8lRH; Path=/api; Secure' ],
Log of request:
first request
[HPM] GET /api/user/getCurrentUserInfo -> https://test.org
Request { _headers:
{ 'accept-encoding': 'gzip',
connection: 'close',
host: 'test.org',
'user-agent': 'Dalvik/1.6.0 (Linux; U; Android 4.4.2; HTC One mini Build/KOT49H)',
cookie: '',
authorization: 'Basic ZmFpdE0OkZhaXQxMjM0ISE=',
accept: 'application/json',
'accept-charset': 'UTF-8' } }
Response {
headers:
{ date: 'Thu, 28 Sep 2017 14:08:47 GMT',
server: 'Apache',
pragma: 'No-cache',
'cache-control': 'no-cache',
expires: 'Thu, 01 Jan 1970 01:00:00 CET',
'set-cookie': [ 'JSESSIONID=dhs-srcyD+z-w6mjCNKS8lRH; Path=/api; Secure' ],
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'application/json' },
statusCode: 200,
statusMessage: 'OK'
}
next request without JSESSIONID cookie
[HPM] POST /api/portfolio/getPortfolioOverview -> https://test.org
Request { _headers:
{ 'content-length': '66',
'accept-encoding': 'gzip',
connection: 'close',
host: 'test.org',
'user-agent': 'Dalvik/1.6.0 (Linux; U; Android 4.4.2; HTC One mini Build/KOT49H)',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
cookie: '',
authorization: 'Basic ZmFpdE0OkZhaXQxMjM0ISE=',
accept: 'application/json',
'accept-charset': 'UTF-8' }
}
Response {
headers:
{ date: 'Thu, 28 Sep 2017 14:08:47 GMT',
server: 'Apache',
'set-cookie': [ 'JSESSIONID=aZnfv5xMRpG9qfjHrocnHxBi; Path=/api; Secure' ],
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'application/json' },
method: null,
statusCode: 500,
statusMessage: 'Internal Server Error'
}
Cordova plugins
cordova plugin ls
cordova-plugin-advanced-http 1.5.10 "Advanced HTTP plugin"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-crosswalk-webview 2.2.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
Can you help we what I am doing wrong. Thanks you
plugin version: 1.9.0
cordova version: 6.5.0
cordova platform versions: android 6.2.3
which platforms are affected:android
example snippet of code:
cordova.plugin.http.setCookie(this.apiAccountUrl, { "sessionid": "" }, {
http: false,
secure: true,
now: new Date(),
ignoreError: false
});
these code went wrong with error:
str.trim is not a function
hi,can this plugin support cancel http request for Android?Or how can i implement this function base the plugin ?
When setting acceptAllCerts to true every request via https returns an error with {"status": -1, "error": "cancelled"}
my code
if(isDevMode()) {
this.http.acceptAllCerts(true).then(
() => console.warn("ALL CERTS WILL BE ACCEPTED!"),
() => console.error("ERROR SETTING acceptAllCerts")
);
}
During development I used to set the option acceptAllCerts to true.
I migrated to ionic 3.7 and from https://github.com/Telerik-Verified-Plugins/SecureHTTP to this plugin (version 1.6.1) as this is now the official ionic-native http plugin and has all the features that made me use SecureHTTP instead of the previous official ionic-native http plugin.
With the old plugin and ionic 3.6 it was never a problem on iOS 10 and after upgrading suddenly nothing worked anymore. Took me a few hours to identify acceptAllCerts as the culprit.
As a workaround I just do no longer use acceptAllCerts in development and test against servers with "proper" certificates.
It would be nice for this to get fixed, or at least have a comment in the docs warning that the option won't work on iOS
Build is working fine for IOS however failing for Android, I get this error:
/Users/olaxx/Desktop/Axx/ixx/platforms/android/src/com/synconset/cordovahttp/CordovaHttpDownload.java:18: error: package org.apache.cordova.file does not exist
import org.apache.cordova.file.FileUtils;
^
/Users/olaxx/Desktop/Axx/ixx/platforms/android/src/com/synconset/cordovahttp/CordovaHttpDownload.java:49: error: cannot find symbol
JSONObject fileEntry = FileUtils.getFilePlugin().getEntryForFile(file);
^
symbol: variable FileUtils
location: class CordovaHttpDownload
Plugin version 1.8.1
My guess is that it just needs to point to the file plugin correctly
System:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 3.0.0
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.7.1
System:
ios-sim : 5.0.8
Node : v6.10.2
npm : 3.10.10
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
I use cordova.plugin.http.post and it keep go to error response. ios 10 and below work fine.
When compiling project with Adobe PhoneGap Build service - https://build.phonegap.com/ - it fails.
/project/src/com/synconset/cordovahttp/CordovaHttpDownload.java:18: error: package org.apache.cordova.file does not exist
import org.apache.cordova.file.FileUtils;
^
/project/src/com/synconset/cordovahttp/CordovaHttpDownload.java:49: error: cannot find symbol
JSONObject fileEntry = FileUtils.getFilePlugin().getEntryForFile(file);
^
symbol: variable FileUtils
location: class CordovaHttpDownload
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
:compileDebugJavaWithJavac FAILEDFAILURE: Build failed with an exception.
There's a mention of cordova-plugin-file in the log also:
Fetching plugin "cordova-plugin-advanced-http@^1.8.1" via npm
Installing "cordova-plugin-advanced-http" at "1.8.1" for android
Fetching plugin "cordova-plugin-file@>=2.0.0" via npm
Installing "cordova-plugin-file" at "5.0.0" for android
Plugin doesn't support this project's cordova-android version. cordova-android: 6.1.2, failed version requirement: >=6.3.0
Skipping 'cordova-plugin-file' for android
Hello I need to consume an api that is made in soap, so the body is an xml like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://ws/api/accesoRequest</wsa:Action><wsa:MessageID>uuid:1792610b-a8f7-4251-9828-f8bf59e51c35</wsa:MessageID></soapenv:Header>
<soapenv:Body>
<ws:acceso>
<!--Optional:-->
<usuario>TEST</usuario>
<!--Optional:-->
<contrasena>TEST</contrasena>
<codigo_consulta>12342</codigo_consulta>
</ws:acceso>
</soapenv:Body>
</soapenv:Envelope>
I send this body as a string:
this.http2.post(SERVER_URL, this.envelopeBuilder(method, this.createXmlBody(method, param)), headers)
.then(data => {
console.log("data", data);
console.log(data.data); // data received by server
this.parseResponse(data.data, cb);
}).catch(error => {
console.log("error", error);
console.log(error.error); // error message as string
console.log(error.headers);
this.parseResponse(null, cb);
});
this.envelopeBuilder(method, this.createXmlBody(method, param)) give me a string and works fine with http from @ angular / http
but with the http of @ ionic-native / http does not work for me, apparently the body is treated and does not arrive as it is to the server.
I am not using @ angular / http since I have cors problem and I do not handle the backend so I have to use ionic native
I think you could create an option for the
this.http2.setDataSerializer
method that insists that the body is raw
Hello,
I have observed that iOS headers are returned in lowercase whereas Android preserves the case sent by the resource. Is this expected?
Thanks,
Hi,
Is there any reason why getCookies in https://github.com/silkimen/cordova-plugin-advanced-http/blob/master/www/cookie-handler.js#L48 is not exposed in ionic?
According to the ionic documentation at https://ionicframework.com/docs/native/http/, the only methods exposed are ClearCookies and RemoveCookies
Thanks,
Cornelius
Hello!
How can I send a GET request with an array parameter?
For example,
http://localhost:8081/rest/v1/payments?clientId=101216&accountIdList=101510&accountIdList=101511
accountIdList sent only so:
http://localhost:8081/rest/v1/payments?clientId=101216&accountIdList=[101510,101511]
Thank you.
Setting up basic authentication via useBasicAuth
is not working when used before setting another header via setHeader
.
We use on a local installed machine a webserver where we install our osgi bundl with our REST apis.
So we can not work with certificates, and also we can not install a signed certifcate, but we have installed a self signed one.
If we use accaptAllCerts
with false obvisouly we get this error
{error: "SSL handshake failed", status: 500}
but if we set it to true we get another error
{error: "There was an error with the request", status: 500}
But it should work right?
It appears that at some point a refactoring changed everything to setDataSerializer
from setParamSerializer
but this was missed in the angular integration:
http.setParamSerializer is not a function. (In 'http.setParamSerializer(serializer)', 'http.setParamSerializer' is undefined)
http://localhost:8100/plugins/cordova-plugin-advanced-http/www/angular-integration.js:46
cordova-plugin-advanced-http doesn't have a header to send csrf token in post request to sap gateway..is there any solution?
I am observing slower total transaction times (request start to resolve) now that I have switched from using iOS WebView to WKWebview + Cordova-HTTP transactions provided by this plugin.
Is it expected that transaction times will increase when switching to this plugin?
Thanks!
Hi
I'm try to send to server a request to a SMSession cookie. All works good on Android, but if I use iOS 11cannot achieve that.
Any ideas about it? Thanks
My ionic info are
ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.0
Cordova Platforms : android 6.3.0 ios 4.5.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
ios-sim : 6.0.0
Node : v7.8.0
npm : 4.2.0
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
Hello,
I'm having a problem with the post method of the plugin, There is a difference in the data structure sent from the iOS and Android client.
This is the function that sends the post request:
getEventsDetails(eventMemberIds) {
return new Promise((resolve, reject) => {
let data = {
emIds: eventMemberIds
};
this.http.post('getEventsDetails', data).then((response: string) => {
resolve(JSON.parse(response));
}).catch((err) => reject(err));
});
}
In the server side this is what I receive:
This plugin works great to enable TLS for post and get functions for Android 4.1+. My issue now is that I need to enable TLS for iframes as well. Can I use this plugin to somehow do that?
I am fetching data from: http://www.spreaker.com/show/2756602/episodes/feed
Simple get method. Promise resolves to error, Response status code is 200, and content of error property is XML content of above given URL.
Am I doing something wrong? Or it is a bug?
Not sure what could be going wrong here, but I cannot get this plugin to work on Android. The error I'm receiving is that cordova.plugin
is undefined. I've tested this within a handler on the deviceready
event, I also set an interval to continually check if it becomes defined, but it does not.
Here is part of my config.xml:
<engine name="android" spec="^6.2.3" />
<engine name="ios" spec="^4.4.0" />
<plugin name="cordova-plugin-advanced-http" spec="^1.5.9" />
Hi,
It's not really an issue but rather a request if you plan to support typescript?
Thank you and Regards,
Cornelius
Kind of a bummer to have to have an if statement to check if it's being viewed via browser platform.
Hello,
I have an issue concerning SSLPinning on iOS with ionic. My code is working well on android but I cannot make it work on iOS. Here is my code:
@Injectable()
@Component({
providers: [CorrespondanceProvider]
})
export class ProductProvider {
...
constructor(@Inject(EnvVariables) public envVariables, public http1: HTTP, private platform:Platform) {
this.platform.ready().then(
() => {
this.http1.validateDomainName(false)
.then(() => this.http1.acceptAllCerts(false)
.then(() => this.http1.enableSSLPinning(true)
.then(() => this.http1.setDataSerializer("json"))));
}
);
}
canLog(credentials, url){
if (this.data){
return Promise.resolve(this.data);
}
let header = { 'Content-Type' : 'application/json'};
let body = {
"credentials":{
"username": credentials.username,
"password": credentials.password
}
};
return new Promise((resolve, reject) => {
this.http1.post(`${this.envVariables.Endpoint}/`+url, body, header)
.then(response => {
this.data = JSON.parse(response.data);
resolve(this.data);
},
err => reject(err)
)
});
}
}
Each time I make a request I get the following error: {"status":-1,"error":"cancelled"} which seems to correspond to a -999 error in AFNetworking.
After a little research, I discovered that acceptAllCerts(true) only put securityPolicy.allowInvalidCertificates to true, which means that it can accept also self signed certificates (even with the enableSSLPinning set to true) and nothing else, while in Android, acceptAllCert(true) is the opposite of enableSSLPinning(true). Please tell me if I am wrong, but this is a little confusing.
Therefore I also tried to set acceptAllCert to true in the code above, but I still get the same error.
(the certificate is in the right place in my project and is found correctly, if I do not put enableSSLPinning to true, everything work fine).
Could you please help?
On iOS responses are checked against a list of allowed content types whereas on Android every content type is allowed.
This is only causing problems, because people are confused receiving an error while having a HTTP status code 200 (e.g. #51). We should remove the white-list and just allow every kind of content type.
Firstly, thank you so much for this plugin. It's the only usable plugin for these kind of requirements.
I noticed a little, but a frustrating issue on iOS. If there is non string value in header object, plugin returns nothing. I didn't stumble upon the same issue on Android however. It works well on there.
For example:
cordova.plugin.http.get('https://google.com/', {
id: 12,
message: 'test'
}, { "somevar": "2" }, function(response) {
console.log(response.status);
}, function(response) {
console.error(response.error);
});
works well. However, if we change "someVar"s value into integer 2, using like this:
cordova.plugin.http.get('https://google.com/', {
id: 12,
message: 'test'
}, { "somevar": 2 }, function(response) {
console.log(response.status);
}, function(response) {
console.error(response.error);
});
That's not working. I'm changing all of the header values to string but, you may want to handle this exception.
Thank you again!
Broken in Android using version 1.6.0, here's the error message:
com/synconset/cordovahttp/CordovaHttpPlugin.java:68: error: constructor CordovaHttpPatch in class CordovaHttpPatch cannot be applied to given types;
CordovaHttpPatch patch = new CordovaHttpPatch(urlString, params, serializerName,
headers, callbackContext);
^
required: String,JSONObject,String,JSONObject,CallbackContext,int
found: String,JSONObject,String,JSONObject,CallbackContext
reason: actual and formal argument lists differ in length
I posted this issue on Ionic Forum, but since it's likely a plugin issue thought I'd post it here as well.
I'm using Ionic Native HTTP plugin 4.3.2
with Ionic Angular 3.7.1
on iOS 11 to POST data to a server. However the request never seems to get executed, it never gets back a HTTPResponse
or even an error.
let url = "https://myserver.com";
let params = { name: 'Me' };
let headers = { 'Accept': 'application/json;charset=UTF-8' };
this.http.post(url, params, headers)
.then((response:HTTPResponse) => {
console.log(`Response ${response.data}`);
})
.catch((error:any) => {
console.error(`Error ${error}`);
});
Doing a GET request works fine returns back a HTTPResponse
, just POST that doesn't seem to work.
I tried to POST to different servers to rule out whether it was a server side issue. Did something break in a recent update of the plugin?
Hi !
I got a no such file or directory www/umd-tough-cookie.js when I try to install this plugin in my Ionic app...
Thank's
Cordially
Is it possible to register background requests ?
So if the app doesn't have internet at the moment, the request is stored and execute later by the OS.
On iOS, I think it can be performed with the property discretionary set on an Background sessions
of a URLSession.
Hello, I am getting JSON error when I would like to send array data in post request
this.http.setDataSerializer("json");
this.http
.post(
"https://localhost/api/create",
[{ test: 1 }, { test: 2 }],
{
"Accept": "application/json",
"Content-Type": "application/json"
}
)
.then((response) => {
console.log('response', response);
})
.catch((error) => {
console.log('error', error);
})
;
I try somethink like below but still same error JSON error
this.http.setDataSerializer("urlencoded");
this.http
.post(
"https://localhost/api/create",
JSON.stringify([{ test: 1 }, { test: 2 }]),
{
"Accept": "application/json",
"Content-Type": "application/json"
}
)
.then((response) => {
console.log('response', response);
})
.catch((error) => {
console.log('error', error);
})
;
Plagin
cordova-plugin-advanced-http 1.5.10 "Advanced HTTP plugin"
How can I send json request with array data?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.