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
What's the philosophy of HtmlUnit when a response contains a header "Content-Type: application/octet-stream" #611
Comments
Maybe a simple solution is to set up your own WebConnectionWrapper and intercept the request url's. For the large ones don's call super and simply return a static response. see https://www.htmlunit.org/faq.html#HowToModifyRequestOrResponse as starting point |
will try to make a bit more detailed description .... |
Sounds like an option.
|
After trying a few small tricks, I achieved the functionality I wanted.
webClient.setAttachmentHandler(new MyxxAttachmentHandler(attachmentList) ); It is work for me now. |
Hi @qurikuduo, slowly i got an idea what you like to do.
Will this help to simplify your code? do you need some other changes for your case? |
@qurikuduo just made a new snapshot build - please try 3.4.0-SNAPSHOT |
Have update the documentation a bit - https://www.htmlunit.org/details.html |
Will close this, hope the changes and the docu are sufficient |
Than you very much. |
Hi there,
Some URL have a response with header "Content-Type: application/octet-stream". Should I process it as an attachment?
After some digs, The Attachment only handle specific response which define in rfc-2183.
the :
attachmentHandler_.isAttachment(webResponse)
will return False when we have "application/octet-stream".
I found org.htmlunit.HttpWebConnection.downloadContent() will be called:
public static DownloadedContent downloadContent(final InputStream is, final int maxInMemory)
It will download the response content.
If I DON'T want HtmlUnit to download big content( e.g. https://dg.10000gd.tech:12348/shmfile/100 ), what should I do?
I want to block download action if a resource lager than 20MB to save on bandwidth.
Thanks a lot.
The text was updated successfully, but these errors were encountered: