public interface AttachmentHandler extends Serializable
A handler for attachments, which represent pages received from the server which contain
Content-Disposition=attachment
headers. Normally pages are loaded inline: clicking on
a link, for example, loads the linked page in the current window. Attached pages are different
in that they are intended to be loaded outside of this flow: clicking on a link prompts the
user to either save the linked page, or open it outside of the current window, but does not
load the page in the current window.
HtmlUnit complies with the semantics described above when an AttachmentHandler
has
been registered with the WebClient
via
WebClient.setAttachmentHandler(AttachmentHandler)
. When
no attachment handler has been registered with the WebClient
, the semantics described
above to not apply, and attachments are loaded inline. By default, AttachmentHandler
s
are not registered with new WebClient
instances.
WebClient.setAttachmentHandler(AttachmentHandler)
,
WebClient.getAttachmentHandler()
,
RFC 2183Modifier and Type | Method and Description |
---|---|
void |
handleAttachment(Page page,
String attachmentFilename)
Handles the specified attached page.
|
default boolean |
handleAttachment(WebResponse response,
String attachmentFilename)
Process the specified attachment.
|
default boolean |
isAttachment(WebResponse response)
Returns
true if the specified response represents an attachment. |
void handleAttachment(Page page, String attachmentFilename)
handleAttachment(WebResponse, String)
has returned false for the response.page
- an attached page, which doesn't get loaded inlineattachmentFilename
- the filename to use for the attachment or null
if unspecifieddefault boolean handleAttachment(WebResponse response, String attachmentFilename)
response
- the response to processattachmentFilename
- the filename to use for the attachment or null
if unspecifiedtrue
if the specified response represents is handled by this methoddefault boolean isAttachment(WebResponse response)
true
if the specified response represents an attachment.response
- the response to checktrue
if the specified response represents an attachment, false
otherwiseCopyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.