Call to an external API via HTTPS from LotusScript - lotus-notes

I need to make a call to a HTTPS based service, from LotusScript.
Previously, I have used:
Set http = CreateObject("Msxml2.ServerXMLHTTP.3.0")
But now we have moved the application to a Domino server on Linux.
My first attempt to replace this code, was to call the shell function, with a call to curl. It works, but the shell function always return an integer, so the response is transferred back to LotusScript as temporary files. The curl solution is rather slow. Approximately 2 seconds response time is too long. The MsXml solution responded in 170 ms!
Then, to get rid of the temporary files, I tried using libcurl, but it requires a callback method to receive the response. It is my understanding that LotusScript is unable to pass callback methods to native methods.
The next attempt was using LS2J to make the HTTP request from Java. It worked, but with a response time of more than 6 seconds, it is useless for our application.
How can I call an external API from LotusScript on Linux, with descent performance?
#IBM: Can we please have a HTTP client and a JSON parser in LotusScript?

LotusScript can declare and call functions in external C libraries, which I suppose you already know from trying to use libcurl. What you can do is write your own C library which acts as a front-end to libcurl. Your C code will have to provide the callback and wait for it to handle the result so you can pass it back to your LotusScript.

I'd suggest to get rid of LS and do what you need to do in Java. In Java you have native libs for http. Or you can use callbacks from C when you use JNA

Related

In NightwatchJS how do I make a synchronous DB call and make Nightwatch wait for the response before moving on

I have a NightwatchJS test that requires a MSSQL Db call to complete before moving on to then verify the results of that db call. The test is 2 parts.
Part 1 fills out a form and submits it into our website and verifies via API in our CMS that the form successfully posted and saves the Guid in a table in another db specifically for Nightwatch testing for verification later.
Part 2 runs later in the day to allow another internal process to 'ingest' that form into a different department's db and return the ingestion results into our CMS for that form. Part 2 then needs to do a Db lookup into the Nightwatch db and get all Guids that happened in the last 24 hours and hit another API endpoint in our CMS to verify ingestion of that form occurred into that other department by checking a field that the other department's process updates on ingestion.
I had the same issue of waiting-to-complete with the API calls where I needed NightwatchJS to wait for the API call to complete in order to use the results in the assertion. To solve that, I used a synchronous http library called 'sync-request'. So, that part works fine.
However, I cannot seem to find a synchronous Db library that works in Nightwatch's world.
I am currently using 'tedious' as my Db library but there is no mechanism for awaiting. I tried promises and async/await to no avail since the async stuff is wrapped inside the library.
I tried Co-mssql but I keep getting an error
TypeError: co(...) is not a function
using their exact example code...
Any ideas or suggestions?
Any other synchronous MSSQL libraries that work in NightwatchJS?
Any way of using 'tedious' is a fashiopn that ensures await-ability?
I found a library called sync-request that blocks the thread which is what i need.

How to hook into node http request?

I want to be able to create beforeRequest/afterRequest hooks so every time node makes http call before/after hook is called with all the data ( method, body, url etc) describing the call.
I have been googling but it seems there is nothing no node native method like http.onBeforeRequest( ({req} => {})). If i remember well there were http.ServerRequest in old node which allows what i need but it is no longer there.
Packages that simplifies http request like https://github.com/sindresorhus/got has own implementation but what i'm looking for is something implementation agnostic.
Thx in advance.

Communicate with api server using nsis

I tried nsis for the first time.
You want to send a post to the api server using nsis.
I used the inetc module, the InetLoad module, and the nsJSON module
All communication is not possible.
Help me, I do not feel at all.
For example, if you have headers, data, and url, you know how to use the module. Please.
I am trying to communicate with the api server using inetc :: post
Pop Returns OK from $ 0.
However, if you look at the server logs, you will see a header check fail.
Why?

Node.Js : How to log a request's body without access to the Request object

I'm currently using a framework in Node.js ( the botbuilder module from Microsoft Bot Framework) which uses the request[2] module to make HTTP requests.
I'm encountering a problem : this framework seems to send a malformed JSON to Microsoft's servers, but I fail to see why and what is this JSON message made of.
So I'm looking for a way to log those messages, to take a peek at this malformed JSON, as I don't have access to the request object (unless I heavily alter the framework code, which is not something one shall do)
So far, I'm able to log the response body (by adding request to the NODE_DEBUG environment variable), but not the original request body. I did try a tcpdump on our server but since it's all HTTPS there's nothing I can use there.
Any idea / tool that might help ?
Thanks for your time.
Use Node.js middleware to log all your requests. For example, you could use the module request-debug.
Another popular request logging middleware worth knowing about is Morgan, from the Express.js server team.

Modifying content delivered by node-http-proxy

Due to some limitations about the web services I am proxying, I have to inject some JS code so that it allows the iframe to access the parent window and perform some actions.
I have built a proxy system with node-http-proxy which works pretty nicely. However I have spent unmeasurable hours trying to modify the content (on my own, using harmon as well, etc) that is being sent to the user without any success. I have found some articles and even some questions here but all of them are outdated and are not useful anymore.
I was wondering if someone can give me an actual example about how to do this, because I am unable to do it and maybe it is just that it is impossible to do at this point?
I haven't tried harmon, but I did try cheerio and it works.
However, I used http-mitm-proxy and not node-http-proxy.
If you are using http-mitm-proxy, you need to return a promise in the response handler. Otherwise, the proxy continues to send the original response without picking up your changes.
I have recently written another proxy at:
https://github.com/noeltimothy/noelsproxy
I'm going to add response handling to this soon. This one uses a callback mechanism, which means it wont return the response until the caller signals it to.
You should be able to use 'cheerio' and alter the content in JQuery style.

Resources