Restrict Feedbin to a maximum of 1 concurrent connection to keep us under Feedbin's 250 requests per second rate limit

This commit is contained in:
Maurice Parker 2019-05-12 07:22:33 -05:00
parent 51c2527da2
commit 60895fc7fa
3 changed files with 30 additions and 3 deletions

View File

@ -179,7 +179,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return delegate.supportsSubFolders
}
init?(dataFolder: String, type: AccountType, accountID: String, transport: Transport = URLSession.webserviceTransport()) {
init?(dataFolder: String, type: AccountType, accountID: String, transport: Transport? = nil) {
switch type {
case .onMyMac:

View File

@ -6,6 +6,10 @@
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
// Feedbin currently has a maximum of 250 requests per second. If you begin to receive
// HTTP Response Codes of 403, you have exceeded this limit. Wait 5 minutes and your
// IP address will become unblocked and you can use the service again.
import Foundation
import RSWeb

View File

@ -41,8 +41,31 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
}
init(transport: Transport) {
caller = FeedbinAPICaller(transport: transport)
init(transport: Transport?) {
if transport != nil {
caller = FeedbinAPICaller(transport: transport!)
} else {
let sessionConfiguration = URLSessionConfiguration.default
sessionConfiguration.requestCachePolicy = .reloadIgnoringLocalCacheData
sessionConfiguration.timeoutIntervalForRequest = 60.0
sessionConfiguration.httpShouldSetCookies = false
sessionConfiguration.httpCookieAcceptPolicy = .never
sessionConfiguration.httpMaximumConnectionsPerHost = 1
sessionConfiguration.httpCookieStorage = nil
sessionConfiguration.urlCache = nil
if let userAgentHeaders = UserAgent.headers() {
sessionConfiguration.httpAdditionalHeaders = userAgentHeaders
}
caller = FeedbinAPICaller(transport: URLSession(configuration: sessionConfiguration))
}
}
var refreshProgress = DownloadProgress(numberOfTasks: 0)