Why okHttp can add Host params in Headers? - okhttp

This is JDK11`s function.The header name or value is restricted by the implementation.But Why OKHttp can add Host in Header? Use JDK11.

Related

Possible if want to do API Load Testing using JMeter with URI info only?

My team planned to do API Performance Testing using JMeter 5.0 for my client. My client developed the API in Kubernetes. Just wondering, they gave info such as URI, HTTP Method and Content-Type only. We never have experience using URI. Are these info sufficient to do load test in JMeter? And where do I fill in these info? Is it in Config Element: HTTP Header Manager?
Because usually I only do my enablement using sample website which already provide the URL.
Do I need to ask them to provide the specific URL for this? Or URL can be extracted from URI?
Thanks.
Normally you should put:
Protocol, server name or IP and Port Number into HTTP Request Defaults, this way you will have a single configuration element having these details and in case of change you will need to introduce the change at one place only and won't have to revisit each and every HTTP Request sampler
Individual requests are defined using individual HTTP Request samplers where you need to provide URL Path and request body (if any)
Content-Type and other Headers can be provided via HTTP Header Manager, the same Scoping Rules as for HTTP Request Defaults apply, for example if you want to send application/json for all the requests just add HTTP Header Manager on the top of your Test Plan and it will add the header to all HTTP Request samplers which are at the same level as the HTTP Header Manager or lower.

How to access host in lambda behind both API gateway and cloudfront?

I have a lambda function being executed by an API gateway. I have cloudfront pointing traffic to the API gateway endpoint.
How do I access the host/domain the client is on in my lambda function?
Can I move the Host header to X-Forwarded-Host?
e.g.
abc.com (cloudfront) -> API gateway -> lambda (Host: abc.com)
In order to propagate Host header through Cloudfront and API Gateway, follow these steps:
Configure Cloudfront to forward Host header
Step-by-step guide
Key points:
Choose the Behaviors tab, and then choose the path that you want to forward the Host header to.
Choose Edit.
Under Cache key and origin requests, confirm that Legacy cache settings is selected. If it's not selected, then follow the steps in the preceding section to create a cache policy. If Legacy cache settings is selected, then complete the following:
For Headers, select Include the following headers.
From the Add header dropdown list, select Host.
Configure API Gateway request to relay Host header
Detailed docs here
Key point:
Edit your API Gateway resource(s) and for each method you need the Host header edit the Method Request by adding Host header in the HTTP Request Headers list.
You can also move the Host header to X-Forwarded-Host using a Cloudfront function but you would still need to follow the steps above to propagate X-Forwarded-Host header. You can try this out starting with this sample function.

set dynamic host and port for Referer with HTTPRequestDefaults

How can I set dynamic host and port for Referer with HTTPRequestDefaults?
I set HTTPRequestDefaults and all hosts and ports of all http requests are blank, so when running the Jmeter they get the value from HTTPRequestDefaults but all referers are static.
forexample if referer is http://172.16.23.10:9080/mycontext/home-login.action?justLogin=true , then I want the referer to read 172.16.23.10 and 9080 from http request default
Note: I know I can use dynamic variables but I want to now if there's a solution with httprequestdefault.
To do this:
Define 2 variables host and port that you'll use in HTTP Request Defaults
Add a HTTP Header Manager as child of Test Plan and define in it the referrer as:
http://${host}:${port}/mycontext/home-login.action?justLogin=true

Override HTTP Authorization Manager in Jmeter

I have a test configured in Jmeter for a HTTP basic auth-protected site. I have an HTTP Authorization Manager configured at the top level with the user/pass for this auth.
There's one http request buried deep in the thread ('Get configurable product options' in the pic below) that I do not want to send the Authorization header with: it's a REST call and I'm sending a bearer Authorization header instead.
I have a HTTP Header Manager assigned to this call with the specific Authorization header defined. All I want is for the Basic Auth header not to be sent, but I cannot for the life of me figure out how.
How do I override this so that the Authorization header set by the HTTP Header Manager overrides the one set by the Authorization Manager?
As per documentation for the HTTP Authorization Manager (JMeter 5.0)
If there is more than one Authorization Manager in the scope of a Sampler, there is currently no way to specify which one is to be used.
So the only way you can override the Authorization header value is using HTTP Header Manager
Add HTTP Header Manager as a child which header you want to override
Configure it as follows:
Name: Authorization
Value: ${__base64Encode(username:password,)}
Replace username and password with your real credentials
Keep in mind that __base64Encode() is a custom JMeter function, if you don't have it already you will need to install it via JMeter Plugins Manager

NoVNC: how to specify cookie for WebSocket URL

I want to pass a WebSocket RFB URL to NoVNC library. But this needs an authentication cookie to be provided via headers. How can I tell NoVNC to use cookies during request?
If you are wanting to change the WebSocket path that noVNC uses you can do it via the settings or use the "path" query parameter. Here is where the setting is located in the noVNC UI:
If you are interested in noVNC Token-based target selection then you can set the "token" query param for the WebSocket path (not the noVNC URL). In other words, a noVNC URL with a websockify token specified would look something like this:
http://host1:6080?host=host1&port=6080&path=websockify?token=foo

Resources