Hello,
I have a very strange behavior, I build on a Java program a request to query a site. For your information, here is the code, but it's not the root of the problem:
conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(SimpleCrawler.timeout);
conn.setReadTimeout(SimpleCrawler.timeout);
conn.setRequestProperty( "Host", url.getAuthority() );
conn.setRequestProperty( "User-Agent", userAgent );
conn.setRequestProperty( "Accept", SimpleCrawler.acceptPageType);//text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
conn.setRequestProperty( "Accept-Language", SimpleCrawler.acceptLanguage );
conn.setRequestProperty( "Accept-Encoding", "gzip, deflate, br" );
InputStream input = conn.getInputStream();
byte[] buffer = new byte[4096];
int n;
OutputStream output = new FileOutputStream( chemin );
while ((n = input.read(buffer)) != -1)
{
output.write(buffer, 0, n);
}
output.close();
And the request downloads a corrupted file. Now if I go through fiddler with this code :
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888));
conn = (HttpURLConnection) url.openConnection(proxy);
I see the request go through Fiddler and the file downloads correctly.
It's as if Fiddler modified the return or the request by reorganizing something to correct a problem that was there before. But I can't figure out what it is, if I knew I'd fix my problem.
Do you have any idea why I am seeing this behavior?
Thanks