Skip to content

Commit

Permalink
Auto merge of #14741 - mattnenterprise:use-http-connection-pool, r=jdm
Browse files Browse the repository at this point in the history
Reuse the http connector pool between fetches

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #14697

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14741)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Dec 27, 2016
2 parents 93e3c3f + ed075ab commit 5d180af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/net/http_loader.rs
Expand Up @@ -72,6 +72,7 @@ pub struct HttpState {
pub cookie_jar: Arc<RwLock<CookieStorage>>,
pub auth_cache: Arc<RwLock<AuthCache>>,
pub blocked_content: Arc<Option<RuleList>>,
pub connector_pool: Arc<Pool<Connector>>,
}

impl HttpState {
Expand All @@ -81,6 +82,7 @@ impl HttpState {
cookie_jar: Arc::new(RwLock::new(CookieStorage::new(150))),
auth_cache: Arc::new(RwLock::new(AuthCache::new())),
blocked_content: Arc::new(None),
connector_pool: create_http_connector(),
}
}
}
Expand Down Expand Up @@ -1021,15 +1023,15 @@ fn http_network_fetch(request: Rc<Request>,

// Step 2
// TODO be able to create connection using current url's origin and credentials
let connection = create_http_connector();

// Step 3
// TODO be able to tell if the connection is a failure

// Step 4
let factory = NetworkHttpRequestFactory {
connector: connection,
connector: context.state.connector_pool.clone(),
};

let url = request.current_url();

let request_id = context.devtools_chan.as_ref().map(|_| {
Expand Down
1 change: 1 addition & 0 deletions components/net/resource_thread.rs
Expand Up @@ -325,6 +325,7 @@ impl CoreResourceManager {
cookie_jar: group.cookie_jar.clone(),
auth_cache: group.auth_cache.clone(),
blocked_content: BLOCKED_CONTENT_RULES.clone(),
connector_pool: group.connector.clone(),
};
let ua = self.user_agent.clone();
let dc = self.devtools_chan.clone();
Expand Down

0 comments on commit 5d180af

Please sign in to comment.