Package ai.preferred.venom.request
Class VRequest.Builder<T extends VRequest.Builder<T>>
- java.lang.Object
-
- ai.preferred.venom.request.VRequest.Builder<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(Request.Method method, String url)
Constructs an instance of builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addHeader(String name, String value)
Adds header to be usedT
addHeaders(Map<String,String> headers)
Add headers to be usedVRequest
build()
Builds the request with the options specified.static VRequest.Builder
delete(String url)
Creates a new instance of builder with method type delete.static VRequest.Builder
get(String url)
Creates a new instance of builder with method type get.static VRequest.Builder
head(String url)
Creates a new instance of builder with method type head.static VRequest.Builder
options(String url)
Creates a new instance of builder with method type options.static VRequest.Builder
post(String url)
Creates a new instance of builder with method type post.static VRequest.Builder
put(String url)
Creates a new instance of builder with method type put.T
removeHeader(String name)
Remove a header from this request.T
removeHeaders()
Remove all headers from this request.T
setBody(String body)
Sets the request body to be used.T
setProxy(org.apache.http.HttpHost proxy)
Sets the proxy to be used, this will override the proxy selected in Fetcher for this request.T
setSleepScheduler(SleepScheduler scheduler)
Sets the sleep scheduler to be used, this will override the sleep scheduler defined in Crawler for this request.T
setUrl(String url)
Sets the url to be fetched.
-
-
-
Constructor Detail
-
Builder
protected Builder(Request.Method method, String url)
Constructs an instance of builder.- Parameters:
method
- The method for this requesturl
- The url for this request
-
-
Method Detail
-
get
public static VRequest.Builder get(String url)
Creates a new instance of builder with method type get.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
post
public static VRequest.Builder post(String url)
Creates a new instance of builder with method type post.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
head
public static VRequest.Builder head(String url)
Creates a new instance of builder with method type head.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
put
public static VRequest.Builder put(String url)
Creates a new instance of builder with method type put.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
delete
public static VRequest.Builder delete(String url)
Creates a new instance of builder with method type delete.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
options
public static VRequest.Builder options(String url)
Creates a new instance of builder with method type options.- Parameters:
url
- url to fetch.- Returns:
- an instance of builder.
-
setBody
public final T setBody(String body)
Sets the request body to be used.- Parameters:
body
- request body- Returns:
- this
-
setSleepScheduler
public final T setSleepScheduler(SleepScheduler scheduler)
Sets the sleep scheduler to be used, this will override the sleep scheduler defined in Crawler for this request. Defaults to none.- Parameters:
scheduler
- sleep scheduler to be used.- Returns:
- this
-
setProxy
public final T setProxy(org.apache.http.HttpHost proxy)
Sets the proxy to be used, this will override the proxy selected in Fetcher for this request. Defaults to none.- Parameters:
proxy
- proxy to be used.- Returns:
- this
-
removeHeader
public final T removeHeader(String name)
Remove a header from this request.- Parameters:
name
- The key of the header to remove- Returns:
- this
-
removeHeaders
public final T removeHeaders()
Remove all headers from this request.- Returns:
- this
-
addHeaders
public final T addHeaders(Map<String,String> headers)
Add headers to be usedThis will merge with headers set in Crawler class. If a same key is found, this will override that header in Crawler class.
- Parameters:
headers
- request headers- Returns:
- this
-
addHeader
public final T addHeader(String name, String value)
Adds header to be usedThis will merge with headers set in Crawler class. If a same key is found, this will override that header in Crawler class.
- Parameters:
name
- name/key of the headervalue
- value of the header- Returns:
- this
-
setUrl
public final T setUrl(String url)
Sets the url to be fetched.- Parameters:
url
- url to fetch.- Returns:
- this
-
build
public VRequest build()
Builds the request with the options specified.- Returns:
- an instance of Request.
-
-