Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete? #1

Open
arjunmenon opened this issue May 10, 2018 · 3 comments
Open

Complete? #1

arjunmenon opened this issue May 10, 2018 · 3 comments

Comments

@arjunmenon
Copy link

arjunmenon commented May 10, 2018

Hey
Is this project complete? Would like to use it instead of what cordova webview allows. Cordova doesn't allow connections unless it is defined in the config.xml

Also, the Android's okhttp library allows custom http requests. No need to specifically set a methods list. Some servers like Upnp asks it to connect by SUBSCRIBE and NOTIFY.

Would be nice if the lib allows it to set other HTTP methods, even for the ios versions

@ihadeed
Copy link
Member

ihadeed commented May 10, 2018

Hey

It's still work in progress..

Basic functionality should work fine (get/post) .. other things like SSL pinning or download/upload will not work.

@arjunmenon
Copy link
Author

How do you build headers though here?
This is what I used to send using XHR

var payload3 = `<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
  	<InstanceID>0</InstanceID>
  </u:GetTransportInfo>
 </s:Body>
</s:Envelope>`;


var xmlHTTP2 = new XMLHttpRequest();

xmlHTTP2.open('POST', 'http://192.168.1.6:49152/ctl/AVTransport', true);

xmlHTTP2.setRequestHeader('SOAPAction', '"urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"');
xmlHTTP2.setRequestHeader('Content-Type', 'text/xml; charset="utf-8"');
xmlHTTP2.onreadystatechange = function() {
  if(xmlHTTP2.readyState === xmlHTTP2.DONE) {

        console.log(xmlHTTP2.responseText);
    } else {
        console.log("not OK: " + JSON.stringify(xmlHTTP2));

  }
};

xmlHTTP2.send(payload3);

Payload is actually a command substitution, notice the backtick

@ihadeed
Copy link
Member

ihadeed commented May 12, 2018

See the method signatures here:
https://github.com/zyra/cordova-plugin-native-http/blob/master/www/NativeHttp.ts#L190-L206

The third param is headers for all of them, you can pass an object there.

const payload3 = `<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
  	<InstanceID>0</InstanceID>
  </u:GetTransportInfo>
 </s:Body>
</s:Envelope>`;

const path = 'http://192.168.1.6:49152/ctl/AVTransport';

const headers = {
  SOAPAction: '"urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"',
  'Content-Type': 'text/xml; charset="utf-8"'
};

NativeHttp.post(path, {}, headers, payload3, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants