Closed tudordumitriu closed 1 year ago
Not sure if this is something we can do about that. Maybe it's something special in your setup.
Did you try using fetch instead of XMLHttpRequest? I am using it successfully for POST requests and never had any issues with the body.
Could you create a minimal reproduction app?
I think you should investigate this further on your side and may need to patch it yourself. PRs, comments welcome.
Still working on it, but what we did was to force the usage of fetch (instead of xhr), which did work until we had to upload a file. File upload, since we needed upload progress is done via xhr, and it crashes, but what is even more strange is that it crashes in webproxy with "Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)" when accessing the urlSchemeTask.request.URL; So I suspect is the same issue, just can't tell what it is yet. Will try to create a minimal reproduction environment, even though is quite complicated.
@NiklasMerz I have put together and example where xhr body is empty https://github.com/tudordumitriu/cordova-webproxy-xhr-test No matter what you want to post in body in the plugin code the request has no body.
Hi @NiklasMerz Did you manage to reproduce it? Do I need to provide extra info or should I try a completely different alternative, because at the time being we're completely stuck.
Unfortunately I don't have the time to look at this right now. I fear you must debug this yourself.
As I never had issues like this so far this could be an edge case specific to your application.
@NiklasMerz That is an entirely new project, created from scratch, and is using vanilla XHR to call, tested on iOS device, cordova 6.2.0., cordova webroxy plugin So it has absolutely nothing to do with our app, I have just followed your request in trying to reproduce it, and started from zero, and there are 2 calls to a local API endpoint that can be emulated via any framework.
I understand thanks for the issue and reproduction. It's great to have this simplified example. It's probably a strange quirk that happens with XHR and how we built this proxy. XHR is quite strange and I don't know it well enough. As I am using fetch with no problems I don't see this as an urgent issue. That's why I said it has something to do with they way your app uses this stuff. This new feature in cordova-ios is kind of experimental and "my proxy plugin" you are using is just built for a personal need with no support.
You already did a lot of debugging and might find more about this with your example. Cordova is maintained by volunteers and if you find a specific problem you probably need to fix it yourself. That's how I did it many times in the past and I think you can do it, too. If you find a fix I am happy to help but I cannot do the debugging.
Sorry if this sounds rude but please don't ping me every time. As I am not getting paid to do this work, I just do the stuff I want to. That's the nature of open source for me.
No worries at all and sorry for being a little pushy, just that it wasn't clear how things are since you requested a reproduction environment and I tried to be intrusive little as possible (not very successful though). Good to know that you are using fetch, it helps a lot because I kept on assuming that you were using XHR as well and I thought it was working in your case but not in ours. So now at least I know I have to fix it on my own (and PR if I succeed). Thanks again for the great work!
Many times when I build a reproduction I found out something new. It can be a problem in my app or it's easier to debug the minimal reproduction. I hope it HPs you, too.
And we know know where this issue is because of this reproduction.
@tudordumitriu hi, I got to this issue my self in the last days. Did you had any progress or new insights that you can share? In my case i post formdata with file in it and got a nil body.
@tudordumitriu, I am also running into this problem, with the same set up as you describe. When you were able "amend the code of the plugin and force the HTTPBody the server response is successfully returned", are you referring to the cordova-plugin-webview-proxy plugin? Or CDVURLSchemeHandler? Or something else? And how are you forcing the HTTPBody?
I've marked this issue as stale because it's been over a year with no further comments. If this is still an issue in the latest cordova-ios version and an up-to-date iOS version, please let us know. Otherwise, this issue will be closed.
Closing as stale.
Bug Report
We have fully set up the cordova-ios 6.2.0 + installed web-proxy plugin + converting all the urls to be routed through the webproxy. Unfortunately the very first call fails and after debugging it I have noticed that the urlSchemeTask.request.HTTPBody is nil even though from Javascript the body is correctly set up, in plugin code there is no body ( even though in Javascript the body is a json "{"name":"t","password":"1"}") and the headers are correctly set and transmitted.
The call is correctly routed to our server because the response headers contain the server details but we are getting back a 400 Bad Request. If we amend the code of the plugin and force the HTTPBody the server response is successfully returned
Few more (maybe important) details:
This issues was originally reported in https://github.com/GEDYSIntraWare/cordova-plugin-webview-proxy/issues/4 but after debugging a little more the problem seems to be in CDVURLSchemeHandler
Problem
Third party plugin cordova-plugin-webview-proxy is not receiving the HttpBody and is not passing it forward.
Environment, Platform, Device
cordova-ios@6.2.0 iPhone 12 Pro
Version information
Cordova: Cordova 9, Cordova iOS 6.2.0 Plugins: https://github.com/GEDYSIntraWare/cordova-plugin-webview-proxy OS: iOS 14.3 , XCode 12.3
Checklist