0

I wrote below sample program to check response of http

 public class CloseableHttpClientExmpl { public static void main(String[] args) { CloseableHttpClient client =HttpClients.custom().disableContentCompression().build(); HttpGet request = new HttpGet("http://localhost:8080/index.php"); CloseableHttpResponse response=null; try { response = client.execute(request); System.out.println(response); } catch (ClientProtocolException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } } 

The output/response is like below

HttpResponseProxy{HTTP/1.1 200 OK [Date: Thu, 11 Apr 2019 12:48:38 GMT, Server: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.8, X-Powered-By: PHP/7.0.8, Content-Length: 79, Keep-Alive: timeout=5, max=99, Connection: Keep-Alive, Content-Type: text/html; charset=UTF-8] ResponseEntityProxy{[Content-Type: text/html; charset=UTF-8,Content-Length: 79,Chunked: false]}} 

Now I want to know that How can I remove software informations like below from this response

Server: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.8, X-Powered-By: PHP/7.0.8 

1 Answer 1

0

Server details mention below are sent by the server i.e. localhost in your case.

Server: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.8, X-Powered-By: PHP/7.0.8 

You can disable 'Server' details sent as a part of the response in your server configuration. For windows server, using https://www.saotn.org/remove-iis-server-version-http-response-header/

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a way to achieve the same through programming?
@ManojKumarDhakad Those values are headers in the response - they're not in the body of the response. As sauumum said, to stop the server sending them you need to change the configuration on the server. If on the client side - in your code - you are not interested in those values then just ignore the headers part of the response and look at the body.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.