Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.io.EOFException on urls that return content-length: 0 #323

Open
smatei opened this issue Mar 28, 2018 · 0 comments
Open

java.io.EOFException on urls that return content-length: 0 #323

smatei opened this issue Mar 28, 2018 · 0 comments

Comments

@smatei
Copy link

smatei commented Mar 28, 2018

Hi,

I see java.io.EOFException in the console when I execute the following code:

` JBrowserDriver driver = new JBrowserDriver();

			driver.get("https://www.bing.com/");
			
			System.out.println(driver.getStatusCode());
			
			System.out.println(driver.getPageSource());
			
			driver.close();`

Console output:

  		[2018-03-28T07:27:04.810][Instance 1][Port 52893] java.io.EOFException
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.readUByte(Unknown Source)
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.readUShort(Unknown Source)
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.<init>(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.<init>(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.machinepublishers.jbrowserdriver.ResponseHandler.handleResponse(ResponseHandler.java:54)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.machinepublishers.jbrowserdriver.StreamConnection.getInputStream(StreamConnection.java:408)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.sun.webkit.network.URLLoader.receiveResponse(URLLoader.java:507)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:164)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.sun.webkit.network.URLLoader.lambda$run$98(URLLoader.java:129)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.security.AccessController.doPrivileged(Native Method)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at com.sun.webkit.network.URLLoader.run(URLLoader.java:128)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.concurrent.FutureTask.run(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 	at java.lang.Thread.run(Unknown Source)
			[2018-03-28T07:27:04.811][Instance 1][Port 52893] 

Debugging this issue, I can see one of the urls returning gzip encoding with content-length 0.

  		[2018-03-28T07:27:04.808][Instance 1][Port 52893] URL https://www.bing.com/notifications/render?bnptrigger=%7B%22PartnerId%22%3A%22HomePage%22%2C%22IID%22%3A%22SERP.2000%22%2C%22Attributes%22%3A%7B%22RawRequestURL%22%3A%22%2F%22%7D%7D&IG=7C6554D1E65A4CB2AD6C9F0D1F7127CA&IID=SERP.2000
			[2018-03-28T07:27:04.809][Instance 1][Port 52893] content-type: text/html
			[2018-03-28T07:27:04.809][Instance 1][Port 52893] content-enconding: gzip
			[2018-03-28T07:27:04.809][Instance 1][Port 52893] content-length: 0
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] java.io.EOFException
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.readUByte(Unknown Source)
			[2018-03-28T07:27:04.810][Instance 1][Port 52893] 	at java.util.zip.GZIPInputStream.readUShort(Unknown Source)

I think that in the method com.machinepublishers.jbrowserdriver.ResponseHandler.handleResponse we should return if the content-length of the response is 0, and do not read any input stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant