URIResponse
, java.io.Closeable
, java.lang.AutoCloseable
public class FetchData extends java.lang.Object implements URIResponse, java.io.Closeable
InspectableFileCachedInputStream
is instantiated that will be later used
to read data from the socket and to store them for the later stages (parsing, storing etc.): note
that the memory needed for the buffer of the InspectableFileCachedInputStream
, as well as
the associated overflow file, are created at construction time, and will be disposed only by
calling close()
.
After construction, the fetch(URI, HttpClient, RequestConfig, VisitState, boolean)
method is used to issue the request; after that, all data obtained as a response are available. All data is available until disposal, or until another
call to fetch(URI, HttpClient, RequestConfig, VisitState, boolean)
.
Note that since this object will be populated by one thread and used by another all fields
must be either final
final or volatile
.
Modifier and Type | Field | Description |
---|---|---|
BinaryParser |
binaryParser |
The binary parser associated with this fetched response.
|
long |
endTime |
System.currentTimeMillis() when the GET request was completed. |
java.lang.Throwable |
exception |
The exception thrown in case of a failed fetch, or
null . |
boolean |
inUse |
If true, this istance has been enqueued to the list of results and we are waiting
for the signal of the
ParsingThread that is analyzing it. |
static int |
OVERFLOW_FILES_RANDOM_PATH_ELEMENTS |
The number of path elements for the hierarchical overflow files (see
Util.createHierarchicalTempFile(File, int, String, String) ). |
protected org.apache.http.HttpResponse |
response |
The response from Apache Http Components returned during the last fetch.
|
boolean |
robots |
Whether we are fecthing a robots file.
|
long |
startTime |
System.currentTimeMillis() when the GET request was issued. |
protected boolean |
truncated |
True if the last fetch was truncated because of exceedingly long response body.
|
protected java.net.URI |
url |
The BUbiNG URL associated with this request.
|
VisitState |
visitState |
The visit state associated with this request.
|
Constructor | Description |
---|---|
FetchData(RuntimeConfiguration rc) |
Creates a fetched response according to the given properties.
|
Modifier and Type | Method | Description |
---|---|---|
void |
abort() |
Invokes
AbstractExecutionAwareRequest.abort() on the underlying request. |
void |
close() |
Disposes the underlying
InspectableFileCachedInputStream . |
byte[] |
digest() |
Get the digest
|
void |
digest(byte[] digest) |
Set the digest with a given value
|
void |
fetch(java.net.URI url,
org.apache.http.client.HttpClient httpClient,
org.apache.http.client.config.RequestConfig requestConfig,
VisitState visitState,
boolean robots) |
Fetches a given URL.
|
boolean |
isDuplicate() |
Get whether the current
FetchData is duplicate or not |
void |
isDuplicate(boolean isDuplicate) |
Mark the current
FetchData as duplicated or not duplicated |
long |
length() |
Returns (an approximation of) the length of the response (headers and body).
|
org.apache.http.HttpResponse |
response() |
Returns the response part.
|
java.lang.String |
toString() |
|
java.net.URI |
uri() |
Returns the URI part.
|
public static final int OVERFLOW_FILES_RANDOM_PATH_ELEMENTS
Util.createHierarchicalTempFile(File, int, String, String)
).protected volatile java.net.URI url
public volatile VisitState visitState
protected volatile org.apache.http.HttpResponse response
protected volatile boolean truncated
public volatile long startTime
System.currentTimeMillis()
when the GET request was issued.public volatile long endTime
System.currentTimeMillis()
when the GET request was completed.public volatile java.lang.Throwable exception
null
.public boolean robots
public final BinaryParser binaryParser
public volatile boolean inUse
ParsingThread
that is analyzing it.public FetchData(RuntimeConfiguration rc) throws java.security.NoSuchAlgorithmException, java.lang.IllegalArgumentException, java.io.IOException
rc
- the runtime configuration.java.security.NoSuchAlgorithmException
java.lang.IllegalArgumentException
java.io.IOException
public long length()
We cannot compute easily the exact length because we must deduce it from headers and body length.
public java.net.URI uri()
URIResponse
uri
in interface URIResponse
public org.apache.http.HttpResponse response()
URIResponse
response
in interface URIResponse
public void fetch(java.net.URI url, org.apache.http.client.HttpClient httpClient, org.apache.http.client.config.RequestConfig requestConfig, VisitState visitState, boolean robots) throws java.io.IOException
httpClient
- the client that will be used to fetch url
.url
- the URL to be used to populate this response.visitState
- the VisitState
associated with url
.java.io.IOException
public void digest(byte[] digest)
digest
- the value to be set for digest
public byte[] digest()
FetchData
public void isDuplicate(boolean isDuplicate)
FetchData
as duplicated or not duplicatedisDuplicate
- a boolean value indicating whether the current FetchData
should be marked as duplicated or notpublic boolean isDuplicate()
FetchData
is duplicate or nottrue
if this is duplicate or notpublic java.lang.String toString()
toString
in class java.lang.Object
public void abort()
AbstractExecutionAwareRequest.abort()
on the underlying request.public void close() throws java.io.IOException
InspectableFileCachedInputStream
.close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException