Read all the headers response

Hi,

The following line :

.check(header("something").saveAs("somethingSaved"));

…allows to read/save a header value.

But I must inspect all headers. How to read all header content? I don’t now the variable names.

Thanks.

See you,

Hi,

Sorry, but your question is unclear.

Do you want to inspect all the headers (plural) because you don’t know the name of the header of interest?

Yes, you have understood the initial question.
See you soon. :wink:

That’s not possible atm and honestly I don’t understand your use case.

How could you possibly ignore the name of the header you’re interested in? How does your actual application work? Header names are typically static while values are dynamic.

Please elaborate on your actual use case.

But I don’t know the headers sended by the server.
Hence my question because I want find a variable but I don’t know its name. :wink:

There’s no way to save all the headers atm. If you want to inspect your requests and responses, the way is to lower the logging level.

1 Like

I’m followed your suggest.

With the TRACE contiguration, I read in the log file the headers:

HTTP response:
status:
	200 OK
headers:
	Date: Wed, 18 Oct 2023 14:40:29 GMT
	Server: Apache/2.4.37 (Red Hat)
	Strict-Transport-Security: max-age=15768000
	Expires: 0
	Expires: 0
	Cache-Control: no-cache, no-store, must-revalidate
	Cache-Control: no-cache, no-store, must-revalidate
	X-Powered-By: JSP/2.3
	Pragma: no-cache
	Pragma: no-cache
	Content-Type: text/html;charset=utf-8
	Connection: close
	content-length: 8394

Then I try to read a header value. For example;

public static ChainBuilder mainTests = 
		exec(http("login")
			.get(ADDRESS)
			.check(header("Server").saveAs("headerValue")))
		
		.exec(session -> {
		  System.out.println("header value => " + session.get("headerValue"));
		  return session;
		 }
		);

It’s fine. :wink:

Thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.