How to run multiple http requests on single click in IntelliJ http file instead of running them individually - intellij-idea

I have 10 http requests in http file and want to run them on single click instead of clicking each request and see the output. Subsequent requests use output from previous requests so I want to run them serially in automated way.

At the moment IDEA's text-based HTTP client supports variable substitution and allows to write some simple JavaScript to access response.
All you have to do is create .http file with all your requests defined in a sequence. Then after each request you can add JavaScript block to fill variables that next request(s) require. Example:
### getting json and setting variable retrieved from response body
GET http://httpbin.org/json
> {%
client.global.set("title",response.body["slideshow"]["title"])
%}
### making request using previously set variable as a body
POST http://httpbin.org/anything
Content-Type: text/plain
{{title}}
Next step is running all requests at once like this:

You could use "Run/Debug Configurations", create a few separated files and setup order in window. But you'll get a big task, you cannot wait and setup timeouts for requests.
I guess you should use Jmeter for real work.
You also could try setup simple curl requests in the Linux bases os.

Related

How to add form-data in jmeter

At POST API,
the developer has passed info with form-data
enter image description here
Need to test API in jmeter. But did not find an option for form-data.
So I tried to add with "parameter" and "Body Data", and now I am getting 400 at Response.
enter image description here
enter image description here
form-data assumes submitting a HTML Form, all the inputs need to be provided via "Name" and "Value" parameters:
If this is a multipart/form-data request - you need to tick the appropriate box
In case you need to send any files - specify them in the Files Upload tab:
If your request works fine in Postman the easiest way of replicating it in JMeter would be just recording it using JMeter's HTTP(S) Test Script Recorder
Start the HTTP(S) Test Script Recorder
Import JMeter's certificate into Postman, this way JMeter will be able to intercept and record HTTPS requests
Configure Postman to use JMeter as the proxy so the request to API would go through JMeter
Run your request in Postman
JMeter will generate HTTP Request Sampler and HTTP Header Manager
Correlate dynamic parameters if needed and replace recorded hard coded values with the relevant JMeter Variables
If the request assumes any files upload - make sure that the file(s) are placed in "bin" folder of your JMeter installation.
You should be able to run the request successfully now

Vue--How do I make the <a> tag carry the request header?

How do I make the tag carry the request header? I use the <a> tag to download. And I need to carry a token in the request header.
When you use a tag to download files or link to any document, in general, it is not possible to manipulate extra headers! Browsers will send the typical headers. To solve this problem, following are the alternative solutions.
Your token must be query parameter in the URL so that back-end server can read it.
Or you can use cookies to save the token and browser will ensure that cookies are sent for your request automatically. (For security, ensure that you cookie is HTTP only and rejects CORS requests)
Alternately, if you are not really after downloading the file or simply trying to show on browser, then you can use XHR or fetch where you are free to manipulate headers.

Does GET endpoint triggers underlying APIs on request (with Postman or JMeter)

I'm creating load testing with JMeter.
We have A Single Page Application (React).
Let's say I need to check the endpoint
GET /foo
When you go to that endpoint via the browser it triggers API endpoints (javascript fetch) to retrieve data. Let's say 2 endpoints
GET /api/fooData, GET /api/fooCalendar
My question is: If I request GET /foo with JMeter (or Postman for instance), will it trigger the other endpoints behind the scene like a normal user flow, or I would need to manually check all the endpoints that are being triggered?
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So you will have to create separate HTTP Request samplers for each JavaScript-driven calls. If the calls are made in parallel - it would be better to put them under the Parallel Controller as JMeter executes Samplers sequentially (upside down)

How can i use Jmeter as a normal browser?

I am using jmeter for performance testing
but jmeter only accept JS call they can not pass request like URL.
so my question is that how can i user jmeter as a normal browser for
load testing ?
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
It is possible to configure JMeter to behave more like a real browser when it comes to normal HTTP requests given you:
Tell JMeter to download embedded resources (scripts, styles, fonts, images, sounds, etc.) in parallel
Add HTTP Cache Manager to mimic browser cache when it comes to handling the aforementioned embedded resources
Add HTTP Cookie Manager to represent browser cookies
Add HTTP Header Manager to represent browser headers
JMeter will not automatically kick off the requests triggered by JavaScript as it doesn't have full JavaScript runtime so you will have to add a separate HTTP Request sampler per such a request. If you need to simulate several AJAX requests - consider putting them under the Parallel Controller as browsers execute AJAX request simultaneously

Advanced Scrapy use Middleware

I want to developt many middlewares to be sure websites'll be parse.
This is the workflow I thinks :
First try with TOR + Polipo
If 2 HTTP errors, try without TOR (so website know my IP)
If 2 HTTP errors, try with proxy (use one of my other server to make HTTP REQ)
If 2 HTTP errors, try with random proxy (on list of 100). This is repeat 5 times
If none works, I save informations on ElasticSearch database, to see on my control panel
I'll create a custom middleware, with process_request function wich contains all of this 5 methods. But I don't find how save type of connection (for exemple if TOR not works, but direct connection yes, I want to use this settings for all of my other scrap, for the same website). How can I save this settings ?
Other thinks, I've a pipeline wich download images of items. Is there a solution to use this middleware (idealy with saving settings) to use on it ?
Thanks in advance for you're help.
I think you could use the retry middleware as a starting point:
You could use request.meta["proxy_method"] to keep track of which one you are using
You could reuse request.meta["retry_times"] in order to track how many times you have retried a given method, and then set the value to zero when you change the proxy method.
You could use request.meta["proxy"] to use the proxy server you want via the existing HTTP proxy middleware. You may want to tweak the middlewares ordering so that the retry middleware runs before the proxy middleware.