Remove unnecessary HTTP headers using apache - java

I have a requirement in my application where a header other than default one sent in http request should be suppressed. Right now in my application when i send a request i am able to attach custom header fields.
Is there a way in apache tomcat configuration settings which will suppress headers other than default ones ? , i tried checking few sites, i found how to remove headers in response
http://www.shanison.com/2012/07/05/unset-apache-response-header-protect-your-server-information/
Is there any similar solution to remove request headers?
Thanks in adv.

Related

Mulesoft - Unable to expose the http response headers to client(browser)

I have exposed few response headers through mule unfortnately the clinet (browser ) unable to see or missing the resposne headers at client side. I really dont know what exactly i have to configure in mule for expose the custom header responses to browser.
I see in internet like this header can help me to fix the issue but im not sure and also i dont know how to define this header in mule side.
access-control-expose-headers

How to set headers in https request in mule

I am using mule 3.3.2. I want to set few headers in https request. In http:outbound-endpoint I use http:request-builder to add headers. But it doesn't work in https:outbound-endpoint.
Any help would beappreciated.
To add headers to https request, set-property tag works.

HTTP Status 405 - Request method 'POST' not supported in jmeter

I have recorded a script and running it. But I'm receiving the following error.
HTTP Status 405 - Request method 'POST' not supported in jmeter
I'm not sure whether it is script issue or coding issue.
Our application is installed on HTTPS but security certificate not yet installed.
Could any one please help me out.
It could be one of below
The endpoint you are requesting is not supported for POST, It may support only GET, Please change the method in Jmeter to GET or the method your url supports
The endpoint may expect proper CSRF token. It might mismatch with one you recorded. So Please extract CSRF token from previous request's response and use it. You can do via RegEx Extractor in Jmeter.
JMeter does support POST method so it may be due to:
Endpoint you're using doesn't support POST method (it expects other method(s) like GET, PUT, DELETE, etc.)
You're sending not properly configured request.
The most common reason is missing relevant Content-Type header. You can use HTTP Header Manager in order to send the relevant Content-Type header which is usually application/json for REST or text/xml or similar for SOAP.
See Testing SOAP/REST Web Services Using JMeter article for more information on API testing using JMeter.
You can also consider the following approach:
Use specialized Web Services testing tool like SoapUI or RESTClient to fire a request
Either use aforementioned tool or 3rd-party sniffer like Wireshark to capture the request
Configure JMeter to send exactly the same request

how to check response header from apache

When a request is coming in, it goes through apache sever before going to application server written in tomcat. In most cases, I can set the response header from apache server to return a certain response header like x-frame-options. However, depending on the page and requester, I would like to remove this x-frame-options in the apache layer.
So far, I tried following two options, but both did not work.
apache always set the header to generic, but application server override it to something else based on the condition.
apache Httpd.conf: Header always append X-Frame-Options SAMEORIGIN
Java Code: response.setHeader("X-FRAME-OPTIONS", "DENY");
application server set to something else then apache to check the header before setting to generic.
Java Code: response.setHeader("X-FRAME-OPTIONS", "DENY");
apache httpd.conf: RequestHeader set X-Frame-Options "SAMEORIGIN" env=no_my_header
I don't know what to do at this point. If anyone has any idea, I would appreciate.
Thanks,

glassfish response not getting in gzip compressed

i am working on java with Netbeans IDE and glassfish 3.1.2 i have created in rest services using jaxrs. when request from client is made ,i need to send json data in compressed format.to do this i have enabled the compression in glassfish as shown the following picture
but response got from the server is not compressed using gzip. it is receiving as normal json data. what should i do to overcome this issue
This is a solution for GF 3.1.2.2.
Responses to HTTP requests in version 1.0 are not compressed. You must send your requests in HTTP 1.1 to get gzipped responses from your glassfish server.
More over, you must add the header "Accept-Encoding: gzip" in your http requests.
To get a compressed response you need to have both sides agree to use it. You have configured GlassFish to send compressed responses. I can see that from the picture.
You need to make sure that your request to the services tells GlassFish that it can accept a compressed response. You normally do this by adding the following header to your HTTP requests: Accept-Encoding. You can read about the header in the RFC document that defines HTTP 1.1 request headers.
You can also get a lot of info from reading though SO questions about Accept-Encoding.

Categories