Weird BaseOptions problem in Dio 4.0.0 (Dart) - flutter

I met some strange behavior, which got my mind blow out.
I have a piece of code
import 'package:dio/dio.dart';
...
var baseOptions = BaseOptions(
baseUrl: "http://localhost:8080");
If I run it from simple Dart console program I got this in debugger which at final works OK:
However when I do THE SAME THING somewhere inside Flutter stuff, I get this weird thing which doesn't work:
What's going on here? What am I doing wrong in the Flutter case?

I finally found the answer. I was wrong with my assumptions in this question, but I will not delete it for people who would have the same root cause analysis path as me.
First of all my problem was not weirdness in BaseOptions. The actual error I got from Dio was just string: "XMLHttpRequest error". I started to find anything strange and found divergence in BaseOptions which led me to idea that the problem was the weird BaseOptions. Not it's not. The real root cause was with CORS. Since my build used web based Flutter and an app was opened in Chrome the CORS defense system started to work and prevented the requests from sending. In console Dart app everything was ok since there is no CORS involved. One more problem was that I used POST request type and a custom header, which both are also not very welcome for CORS policies.
So to fix my problem what I had to do - is to fix CORS.
But what is going on with BaseOptions? I don't know for sure but most likely it is related to the way how Dart code compiled to JS. Looks a bit ugly in debugger, but it seems JS needs to know which field comes from which place for some reason.

Related

flutter firebase messaging with http to send push notification. i'm going to crazy becuase of this

status is pointing to 401.
I've double-checked to see if I've entered a key or token incorrectly, but that seems unlikely, because I'm not using a
copy-pasted it verbatim, so I'm guessing that something in the
must be going wrong somewhere else.
What I'm trying to do now is, when the post is commented on
So I asked GPT, and he showed me the code in the same form as the picture I posted. Of course, I'm getting the token through firebase messaging just fine, but the problem is that gpt seems to have written the code with an outdated version of the http package, so I googled for the latest version
so I thought it would work, but it didn't.
I've been struggling with this for hours now, and I'm hoping you guys can help me out.

onvif with gsoap 2.8.62 version get error code (SOAP_EMPTY 52)

I get SOAP_EMPTY using gsoap, I have searched for a long time and had no answer,SOAP_EMPTY is newly added to gsoap,and it seems I'm the unlucky guy to meet this problem.
Here is where my code come from:https://github.com/miibotree/ONVIF/blob/master/main.c
Now soap_call___tds__GetCapabilities will return code SOAP_EMPTY,I'm now using gdb to track this problem it seems that I need to set a valid soap->id to avoid this problem,but I'm a fresh guy with onvif and don't know how to set a valid soap->id,and now I'm reading various docs about onvif and trying to solve it.
Hope any guys could help me, sinch searching so many docs makes my eyes pain and I still haven't found the answer,thanks.
SOAP_EMPTY is a validation failure. This error indicates than an element/attribute is empty but is supposed to have content. For example an integer value should not be an empty string. The old error generated by older gSOAP releases in this case was SOAP_TYPE which was less informative. In either case, validation fails. The best way to find out is to use soap_print_fault() and soap_print_fault_location()` where the latter call shows the location in XML where the problem is. Our ONVIF testing with gSOAP did not reveal such an issue.

Ionic: Disqus embed loads locally, but not in production (or on an emulator)

I've built a simple Android app, as a companion piece to a publication website, with the Ionic framework, and (after much head-banging), I managed to get the Disqus threads on the app to sync with those on the site. After trying a few different methods, I ended up going with this directive from Michael Bromley to implement the Disqus widget in the app, which is hiding behind a "Comments" button at the bottom of each article on the app's UI.
Running with Ionic Serve, everything works brilliantly. Outside of the local server: not so much. I don't get an error message from Disqus – it simply doesn't load the iframe at all. I'm refraining from posting code, because I'm wondering if this is simply a CORS issue, or maybe something simple that I'm overlooking.
One thing that might be of importance: I don't have the Crosswalk plugin installed on the app – I'm not sure if my thinking is correct, here, but could it be possible that Disqus is compatible with Chrome, which is why it runs fine when I'm testing it on my browser, but isn't compatible with Android's default browser? I'm not extremely well-read on Crosswalk, but I believe it tells the app to use a specific browser – if so, could installing it fix the problem? I'd go ahead and install it, and see if it helps, but I'd like to avoid tampering too much with an otherwise-working app if the issue is something completely unrelated to the plugins.
One weird caveat: The Disqus comments loaded on one article just fine when I tested the app on Genymotion. I deleted that article, and created a new Test article on my site (thus firing up a new Disqus thread), and that failed to render on Genymotion. It seems very... random, I guess, that it would work once. It would seem that it would either work all the time, or never work.
EDIT: While running on Genymotion, no errors appear in the console when debugging the app with WebView. The fact that I'm not getting a "Refused to load" error makes me think that Disqus is getting called and, for whatever reason, is refusing to answer the phone at all.
I can spend hours trying to figure something out, and then... well, as soon as I post a question, I end up figuring out the answer five minutes later.
I dug looked into the code for the directive I was using (which I highly recommend for anybody looking to easily implement Disqus into any AngularJS project), and I noticed that was calling for embed.js with the following string:
....
if (!$window.DISQUS) {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + scope.config.disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
} else {
....
Amending dsq.src = '//' + scope.config.disqus_shortname + '.disqus.com/embed.js';to add a protocol, making it dsq.src = 'http://' + scope.config.disqus_shortname + '.disqus.com/embed.js';fixed the issue on Genymotion. I'll ship the updated APK to the Play Store, and comment on this answer to confirm whether or not it holds up there, as well.

Problems getting OSVR to initialise the HMD Display with Oculus DK2

I am using a Oculus DK2 (v0.8) and OSVR SDK. I'm having a problem getting the HMD to run/display anything.
The Oculus samples and the OSVR samples do work however, so the osvr_server seems to run fine.
My application itself renders a test scene just fine when not using a HMD.
I tried two approaches:
First, just creating a osvr context and creating a DisplayConfig object. This seems to work, but DisplayConfig::checkStartup() fails (I do this in a loop, calling update on the context when the checkStartup call is failing). I used the OpenGLSample.cpp as a guide for this
Second, I tried using a RenderManager, but the call to createRenderManager results in a crash within the RenderManager.dll. I get the same crash wether I create the graphics lib object myself or if I let the library create it.
I am quite stuck now, since the demos and examples do work, I have no idea where to look for the error on my side. Creating the context works, querying interfaces as well, but the crash with createRenderManager is beyond me.
Does anyone have any hints or ideas what the problem could possibly be?
Regards and thanks in advance
pettersson
RenderManager should not crash during open. There have been a couple of bug fixes recently to avoid that happening, and the latest RenderManager binaries, libraries and header files are available with the SDK download from http://osvr.github.io/using/ along with updated copies of the example programs.
When something goes wrong in RenderManager, it usually reports that to standard error. We're moving that to a logging interface, but for now it should show up on the console. Posting an output of that as an issue at https://github.com/sensics/OSVR-RenderManager/issues is a good way to let the developers know that there is a problem. Of course, providing the same sort of information you provided here will be helpful as well.

Adding headers to diffy proxy before multicasting

I wanted to use Diffy for my API testing but found that it does not allow customization of headers while sending requests. Our Apis need access tokens which are different in different servers that are passed as HTTP Headers.
I started exploring the Diffy code and tried to resolve this issue (for me) myself.
Understanding the flow/code is a bit difficult for me as I have no experience in scala. However I understood the code a little and tried to add a line of code at
[HttpDifferenceProxy.scala] (https://github.com/twitter/diffy/blob/master/src/main/scala/com/twitter/diffy/proxy/HttpDifferenceProxy.scala)
The Diffy tool executes a Http Request asynchronously after checking whether it is allowed to do so. I added my line of code here before this check to add a header.
object SimpleHttpDifferenceProxy {
lazy val httpSideEffectsFilter =
Filter.mk[HttpRequest, HttpResponse, HttpRequest, HttpResponse] { (req, svc) =>
req.headers().add("Authorization1", "123") //My code here
val hasSideEffects =
Set(Method.Post, Method.Put, Method.Delete).contains(Request(req).method)
if (hasSideEffects)
DifferenceProxy.NoResponseExceptionFuture else svc(req)
} }
Okay I am facing two problems.
The header is not getting added
Any suggestion for a good Scala IDE -- I am using ScalaIDE built on top of Eclipse but the debugging is nowhere close to debugging capabilities of Eclipse in java.
What am I doing wrong here?
Thanks,
Sukalpo.
I found the answers to both my questions and they are the same :)
IntelliJ is the most coolest IDE ever.
Answer for 1:- The headers were getting added. The shitty ScalaIDE that I was using somehow did not show it while I was debugging and wasted my whole day
Answer for 2:- Hands down IntelliJ