Problem: Given a URL, I want to download content from the server only if its an image and below a certain size.
Approach: I decided to send a Head request with "Accept" header set as follows: HttpClient client = new HttpClient(); HttpMethod head = new HeadMethod( url ); head.setRequestHeader( "Accept", "image/jpeg" ); int responseCode = client.executeMethod( head ); Issue: When I do this, I get a 200 (HttpStatus.SC_OK) response for URLs that are not images such as http://www.gutenberg.org/files/18503/18503-8.txt. I was accepting a 406 (HttpStatus.SC_NOT_ACCEPTABLE) Is the "Accept" header ignored by most web servers? Or is something else going on? -- View this message in context: http://www.nabble.com/Question-about-setting-%22Accept%22-header-in-Http-request-tp22606721p22606721.html Sent from the HttpClient-User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
