I'm developing a new module in Chromium solution, in which I want to create and send a request to specific server. I've tried to implement this in many way: call Send() method of URL request directly, use URL fetcher, send via IPC route... but no one could be successful.
Related
I have been trying to intercept a server request using Cypress' intercept method.
I have noticed that Cypress can intercept requests made through the front-end/browser, however, the intercept method doesn't work if I make a request directly to the back-end server.
Let me clarify what I mean:
One thing is intercepting a request that the front-end/browser makes to the back-end server.
Another thing is intercepting a call that doesn't use the browser but calls directly the back-end endpoint.
For example:
I can create a user using the front-end interface
or I can create a user calling the back-end endpoint directly (directly calling the server).
Coming back to my question. Is there a way to intercept a call that was made directly to the back-end endpoint?
This is what I have tried so far:
I wrote a regex to intercept api/v0/customers
I then made a request to http://locahost:5440/api/v0/customers (which is the URL of the server)
Finally, I waited for the request to happen
Timeout request using Cypress intercept method
cy.intercept(/^\/api\/v0\/customers\/$/).as('createCustomer');
cy.request(createCustomer(customerData, headers));
cy.wait('#createCustomer').then(({ status, body }) => {
const customerId = body.customer_id;
console.log(body);
expect(status).equal(201);
});
Here's the problem: There was a timeout error.
As you can see in the image, I'm making a request to http://locahost:5440 which is the server URL. NOTE: I made sure the server was up and running.
The regex is also correct and it will match the endpoint http://locahost:5440/api/v0/customers
I suspect that intercept only works for requests being made through the browser. Is this assertion correct? I couldn't find this answer anywhere in the Cypress docs.
Is there a way for me to intercept a call being made directly to a server (not using the browser)?
You don't have to intercept the requests you explicitly make with cypress, just use .then to get the response, like this:
cy.request(createCustomer(customerData, headers)).then((response) => {
const customerId = response.body.customer_id;
console.log(response.body);
expect(response.status).equal(201);
});
Reference: https://docs.cypress.io/api/commands/request#Yields
UIB Sandbox Access request.
The webhook URL will be receiving a webhook payload as an input.
Get the web hook URL from the application you want to send data
use that URL in webhook section of the application you want to receive data from
choose type of events you want to application to notify you about
Is it legal to send custom requests using my own cookie? For example if I login to a website that provides e-mails and I found that I can send a request like: somewebpage.com?email_id=1&cookie_token=123 then can I send a custom request using eg app written in c++ to get all my emails (by changing email_id)?
I'm using busboy with express.js 4 and node.js to receive via an HTTP POSTa set of field values and an uploaded file from a form in the browser. The file will then be processed (data extracted, new documents created in the database etc.) with the possibility of some of the updates not being successful. What I want to do is update the user what is going on during the processing and then the outcome when all is done.
To do this I want to use HTML5 server sent events. Before some suggests it, I can't use websockets.
When I declare:
var eventSource = new EventSource('/API/upload');
in my browser I see an HTTP GET on the server to this URL. What I want is for eventSource to listen for server sent events from the HTTP POST handler, the route that receives and processes the uploaded metadata and file. My expectation was that in my app.post(... handler I could put:
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
});
res.write('\n');
and then push down status updates using:
res.write(message'\n\n');
res.flush(); // I'm using compression
finally terminating the exchange with res.status(200).end(); after all the processing, updating etc. is done. But of course the browser isn't listening for that EventSource, it's listening for one on the GET route
So, how can I:
configure the browser with an EventStream object that doesn't automatically make a GET request when I instantiate it?
and instead listen for events being sent back from the POST event handler on the server?
David. You cannot do it this way. You could use a PUT request to define where the data is going. E.g. PUT /API/upload/1234. Then you could point your event source at the server to get updates.
new EventSource("/API/upload/1234");
That way the server can report on the process of the job.
I'm using a SaaS for my AWS instance monitoring and Mandrill for email sending/campaigns.
I had created a simple chart with Zapier but I'd rather like to host it myself. So my question is:
How can I receive a webhook signal from Mandrill and then send it to Datadog from my server? Then again I guess hosting this script right on the same server I'm monitoring would be a terrible idea...
Basically I don't know how to "receive the webhook" so I can report it back to my Datadog service agent so it gets updated on their website.
I get how to actually report the data to Datadog as explained here http://docs.datadoghq.com/api/ but I just don't have a clue how to host a listener for web hooks?
Programming language isn't important, I don't have a preference for that case.
Here you can find how to add a new webhook to your mandrill account: https://mandrillapp.com/api/docs/webhooks.php.html#method=add
tha main thing here is this:
$url = 'http://example/webhook-url';
this is your webhook URL what will process the data sent by mandrill and forward the information to Datadog.
and this is a description about what mandrill will send to your webhook URL: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
a listener for webhooks is nothing else then a website/app which triggers an action if a request comes in. Usually you keep it secret or secure it with (http basic) authentication. E.g. create a website called http://yourdomain.com/hooklistener.php. You can then call it with HTTP POST or GET and pass some data like hooklistener.php?event=triggerDataDog or with POST and send data along with the body. You then run a script or anything you want to process that event.
A "listener" is just any URL that you host where you can receive data that is posted to it. Keep in mind, since you mentioned Zapier, you can set up a trigger that receives the webhook data - in this case the listener URL is provided by Zapier, and you can then send that data into any application (or even post to another webhook). Using Zapier is nice because it doesn't require you to write the listener code that receives the hook data and does something with it.