Skip to content

Commit

Permalink
enable decompression by HTTPClient
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Oct 13, 2023
1 parent 02d51ec commit 54e3ff3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Sources/Penny/Penny.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ struct Penny {
/// Use `1` instead of `System.coreCount`.
/// This is preferred for apps that primarily use structured concurrency.
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup))
let httpClient = HTTPClient(
eventLoopGroupProvider: .shared(eventLoopGroup),
configuration: .init(decompression: .enabled(limit: .size(1 << 32)))
)
let awsClient = AWSClient(httpClientProvider: .shared(httpClient))

/// These shutdown calls are only useful for tests where we call `Penny.main()` repeatedly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ struct DefaultSOService: SOService {
let httpClient: HTTPClient
let logger = Logger(label: "DefaultSOService")
let decoder = JSONDecoder()
private static let urlEncodedAPIKey = Constants.StackOverflow.apiKey
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!

func listQuestions(after: Date) async throws -> [SOQuestions.Item] {
let queries: KeyValuePairs = [
"site": "stackoverflow",
"tagged": "vapor",
"nottagged": "laravel", /// Don't be a "laravel" questin
"nottagged": "laravel", /// Don't be a "laravel" question
"page": "1",
"sort": "creation",
"order": "desc",
"fromdate": "\(Int(after.timeIntervalSince1970))",
"pagesize": "100",
"key": Constants.StackOverflow.apiKey,
"key": Self.urlEncodedAPIKey,
]
let url = "https://api.stackexchange.com/2.3/search/advanced" + queries.makeForURLQueryUnchecked()
let request = HTTPClientRequest(url: url)
Expand Down

0 comments on commit 54e3ff3

Please sign in to comment.