Error in Response body in the redirection URL in Jmeter - testing

I am trying to do a performance testing for a project where the main URL performs a redirection and the redirection URL returns the token needed to proceed further.
I recorded the script with Jmeter and i can see that the main URL does the redirection with status code as "302" as expected and has the "Location" header in the response body.
But when the redirection URL is hit after the main URL as the sub sample, it returns "307 temporary redirection" in response header and an error message in the response body as "java.lang.IllegalArgumentException: Missing location header in redirect for GET "
I checked the same scenario in Neoload and i could notice that request sent in Neoload for rediection URL is same as the one sent in JMeter, the response header also matches. But Neoload was able to display the response body with the expected token. In Jmeter, it returned the error message.
Can someone clarify why the response body is not displayed in Jmeter if the same request can work in Neoload. I made sure there is no difference in the request header/body sent for the main URL.
I am pretty sure the issue is related to Jmeter but not sure how to get the proper response body.

Maybe there is more than one redirect and JMeter doesn't follow it.
You can play with Redirect automatically and/or Follow redirects boxes in HTTP Request sampler
also you can use a third-party sniffer tool like Wireshark or Fiddler to inspect which requests are actually being sent, pay attention to literally everything: URL, headers, body, etc.
It should also be possible to disable handling redirects in JMeter completely and extracting the redirect target from the Location header using Regular Expression Extractor or Boundary Extractor and manually add the next request giving the extracted URL in the "Path" field of the HTTP Request sampler

Related

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.

How to pass original URI, with arguments, to Traefik ErrorPage handler specified in `query`?

I'm trying to use nginx to serve a custom error page using the Error Page middleware so that 404 requests to a lambda service (which I don't control) can be handled with a custom error page. I want to be able to get the context of this original request on that error page, either in Nginx for further forwarding, or else as a header for further handling e.g. in PHP or whatnot so I can provide contextual links on the 404 page.
However, right now after the redirection to Nginx in Traefik's ErrorPage middleware it seems the request has lost all the headers and data from the original service query.
The relevant part of my dockerfile:
traefik.port=8080
traefik.protocol=http
traefik.docker.network=proxy
traefik.frontend.rule=PathPrefix:/myservice;ReplacePathRegex:^/myservice/(.*) /newprefix/$$1
traefik.frontend.errors.myservice.status=404
traefik.frontend.errors.myservice.service=nginx
traefik.frontend.errors.myservice.query=/myservice-{status}
Nginx receives the forwarded 404 request, but the request URI comes through as nothing more than the path /myservice-404 specified in query (or /, if I omit traefik.frontend.errors.myservice.query). After the ReplacePathRegex I have the path of the original request available in the HTTP_X_REPLACED_PATH header, but any query arguments are no longer accessible in any header, and nginx can't see anything else about the original URI. For example, if I requested mysite.com/myservice/some/subpath?with=parameters, the HTTP_X_REPLACED_PATH header will show /myservice/some/subpath but not include the parameters.
Is it possible in Traefik to pass another service the complete context about the original request?
What I'm really looking for is something like try_files, where I could say "if this traefik request fails, try this other path instead", but I'd settle for being able to access the original, full request arguments within the handling backend server. If there was a way to send Nginx a request with the full path and query received by Traefik, that would be ideal.
tl;dr:
I am routing a request to a specific service in Traefik
If that request 404s, I want to be able to pass that request to Nginx for further processing / a contextual error page
I want Nginx and/or the page which receives the ErrorPage redirect to be able to know about the request that 404'd in the service
Unfortunately this is not possible with Traefik. I tried to achieve something similar but I realized that the only information that we are able to pass to the error page is the HTTP code, that's it.
The only options available are mentioned in their docs: https://doc.traefik.io/traefik/middlewares/errorpages/

How to modify the response header based on the content of response body in IBM http server?

I have a scenario in which the IHS server is used as a reverse proxy. Any request from the browser reaches the webserver (ie IHS) and IHS redirects the request to the corresponding URL. Similarly the response will return back to IHS and then to the browser. Now I need to include the user ID in the response header. This user ID which I need to include in the header needs to be obtained from the body of the response.
Please help if this is possible as I am new to IHS.
You can't do this in an Apache-based proxy server. Headers are sent before the body, and the body is not buffered and scanned for content in any standard Apache module.
If you need to set a response header to the logged in user, do it in your application.

How to add HTTP header to URL

I'm working with an API which provides a HTTP header called token with value 12abc3 and my url is https://example.com/view/quote. Is there a way by which I can add the header as a parameter in the url so that I can type it directly on my browser's address bar instead of using cURL orHurl.it??
The only way I can imagine being able to do this would be to write a small HTTP proxy that takes a specially formatted URL and extracts header values out of the URL and re-issues the request for you. I'm not aware of any service to do this automatically for you.
I think it's too late to reply but for those who still finding the solution
you can send your token through url like this
https://yoururl?Authorization=Bearer yourtokenhere

Jmeter error 404

I am trying to load test a webapp, which has following functonality
1. Login in app (setting some cookie variables )
2. Serach customer with some parameter
3. Get detail of particular customer
4. Logout from webapp
When i am running Jmeter i am getting status code 404
Any reference or help will be appriciated.
After googling i found 4** says you have sent bad request.
To check what request has been sent i am using fiddler and capturing original request (which is working from browser ) and request sent by Jmeter , I am comparing data under Inspector tab in Headers in fiddler, Is this right way to resolve the issue of 4**. What else i can do to fix this issue ?
Screen shots attached
I think, the HTTP header manager and HTTP cookie manager must be pushed up just before Recording Controller. Otherwise the requests are made without these header or cookie informations.
If you doing localhost testing should in the cookie manager config domain
localhost:8080.
You can see the request/response in View Results Tree. Just click on the tab Request or Response data respectively. If you're getting a 404, chances are the Response data tab will contain the 404 with (hopefully) information about the values that are invalid or missing.