Skip to content

Commit

Permalink
Connection and socket timeouts are configurable now
Browse files Browse the repository at this point in the history
  • Loading branch information
amir343 committed Apr 11, 2012
1 parent 19c13d5 commit 4620db9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/scala/com/gravity/goose/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class Configuration {
@BeanProperty
var imagemagickIdentifyPath: String = "/opt/local/bin/identify"

@BeanProperty
var connectionTimeout: Int = 10000

@BeanProperty
var socketTimeout: Int = 10000

/**
* used as the user agent that is sent with your web requests to extract an article
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/com/gravity/goose/network/HtmlFetcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ object HtmlFetcher extends Logging {
httpget = new HttpGet(cleanUrl)
HttpProtocolParams.setUserAgent(httpClient.getParams, config.getBrowserUserAgent());

val params = httpClient.getParams
HttpConnectionParams.setConnectionTimeout(params, config.getConnectionTimeout())
HttpConnectionParams.setSoTimeout(params, config.getSocketTimeout())

trace("Setting UserAgent To: " + HttpProtocolParams.getUserAgent(httpClient.getParams))
val response: HttpResponse = httpClient.execute(httpget, localContext)

Expand Down

0 comments on commit 4620db9

Please sign in to comment.