Interface AttachmentHandler
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
CollectingAttachmentHandler
public interface AttachmentHandler extends java.io.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 theWebClient
viaWebClient.setAttachmentHandler(AttachmentHandler)
. When no attachment handler has been registered with theWebClient
, the semantics described above to not apply, and attachments are loaded inline. By default,AttachmentHandler
s are not registered with newWebClient
instances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
handleAttachment(Page page)
Handles the specified attached page.default boolean
handleAttachment(WebResponse response)
Process the specified attachment.default boolean
isAttachment(WebResponse response)
Returnstrue
if the specified response represents an attachment.
-
-
-
Method Detail
-
handleAttachment
void handleAttachment(Page page)
Handles the specified attached page. This is some kind of information that the page was handled as attachment. This method will only be called ifhandleAttachment(WebResponse)
has returned false for the response.- Parameters:
page
- an attached page, which doesn't get loaded inline
-
handleAttachment
default boolean handleAttachment(WebResponse response)
Process the specified attachment. If this method returns false, the client will open a new window with a page created from this response as content. Overwrite this method (and return true) if you do not need to create a new window for the response.- Parameters:
response
- the response to process- Returns:
true
if the specified response represents is handled by this method- See Also:
- RFC 2183
-
isAttachment
default boolean isAttachment(WebResponse response)
Returnstrue
if the specified response represents an attachment.- Parameters:
response
- the response to check- Returns:
true
if the specified response represents an attachment,false
otherwise- See Also:
- RFC 2183
-
-