New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]Access http response #41
Conversation
@@ -27,6 +27,10 @@ import Foundation | |||
import XCTest | |||
@testable import DBNetworkStack | |||
|
|||
extension HTTPURLResponse { | |||
static let defaultTestResponse = HTTPURLResponse(url: URL(string: "bahn.de")!, mimeType: nil, expectedContentLength: 1, textEncodingName: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
@lightsprint09 I'm missing a description of the PR goals |
Source/NetworkServiceMock.swift
Outdated
@@ -84,9 +84,9 @@ public class NetworkServiceMock: NetworkServiceProviding { | |||
/// - Parameters: | |||
/// - data: the mock response from the server. `Data()` by default | |||
/// - count: the count how often the response gets triggerd. 1 by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing httpResponse parameter doc
Source/NetworkServiceMock.swift
Outdated
@@ -98,9 +98,9 @@ public class NetworkServiceMock: NetworkServiceProviding { | |||
/// - Parameters: | |||
/// - data: the mock response from the server. `Data()` by default | |||
/// - count: the count how often the response gets triggerd. 1 by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing httpResponse parameter doc
@@ -61,15 +61,15 @@ public final class RetryNetworkService: NetworkServiceProviding { | |||
} | |||
|
|||
@discardableResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing function documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a protocol implementation. So the method is documented by the protocol
Codecov Report
@@ Coverage Diff @@
## develop #41 +/- ##
===========================================
+ Coverage 86.3% 87.16% +0.86%
===========================================
Files 17 17
Lines 292 296 +4
===========================================
+ Hits 252 258 +6
+ Misses 40 38 -2
Continue to review full report at Codecov.
|
import Foundation | ||
|
||
extension URL { | ||
static let defaultMock: URL = URL(string: "bahn.de")! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
import Foundation | ||
|
||
extension URL { | ||
static let defaultMock: URL = URL(string: "bahn.de")! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
import Foundation | ||
|
||
extension URL { | ||
static let defaultMock: URL = URL(string: "bahn.de")! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
Source/RetryNetworkService.swift
Outdated
}, dispatchRetry: { [weak self] disptachTime, block in | ||
self?.dispatchRetry(disptachTime, block) | ||
}) | ||
retryTask.originalTask = networkService.request(resource, onCompletion: onCompletion, onError: retryTask.createOnError()) | ||
retryTask.originalTask = networkService.request(queue: queue, resource: resource, onCompletionWithResponse: onCompletionWithResponse, onError: retryTask.createOnError()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 160 characters or less: currently 177 characters (line_length)
Source/RetryNetworkService.swift
Outdated
}, dispatchRetry: { [weak self] disptachTime, block in | ||
self?.dispatchRetry(disptachTime, block) | ||
}) | ||
retryTask.originalTask = networkService.request(resource, onCompletion: onCompletion, onError: retryTask.createOnError()) | ||
retryTask.originalTask = networkService.request(queue: queue, resource: resource, onCompletionWithResponse: onCompletionWithResponse, onError: retryTask.createOnError()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 160 characters or less: currently 177 characters (line_length)
Source/RetryNetworkService.swift
Outdated
}, dispatchRetry: { [weak self] disptachTime, block in | ||
self?.dispatchRetry(disptachTime, block) | ||
}) | ||
retryTask.originalTask = networkService.request(resource, onCompletion: onCompletion, onError: retryTask.createOnError()) | ||
retryTask.originalTask = networkService.request(queue: queue, resource: resource, onCompletionWithResponse: onCompletionWithResponse, onError: retryTask.createOnError()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 160 characters or less: currently 177 characters (line_length)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the typo, everything looks fine 👍
} | ||
} catch { | ||
} catch let parsingError { | ||
let dbBetworkError: DBNetworkStackError! = parsingError as? DBNetworkStackError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbBetworkError
=> dbNetworkError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦇 -Work??
Source/NetworkServiceProviding.swift
Outdated
@@ -33,11 +33,11 @@ import Dispatch | |||
*/ | |||
public protocol NetworkServiceProviding { | |||
/** | |||
Fetches a resource asynchrony from remote location | |||
Fetches a resource asynchrony from remote location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean 'asynchronously'?
Source/NetworkServiceProviding.swift
Outdated
@@ -49,9 +49,20 @@ public protocol NetworkServiceProviding { | |||
|
|||
public extension NetworkServiceProviding { | |||
/** | |||
Fetches a resource asynchrony from remote location | |||
Fetches a resource asynchrony from remote location. Completion and Error block will be called on the main thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
Source/NetworkServiceProviding.swift
Outdated
@@ -49,9 +49,20 @@ public protocol NetworkServiceProviding { | |||
|
|||
public extension NetworkServiceProviding { | |||
/** | |||
Fetches a resource asynchrony from remote location | |||
Fetches a resource asynchrony from remote location. Completion and Error block will be called on the main thread. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo code should be part of Playground
Fixes issues: #49 , #39
New feature:
When doing a network request, you may want to access the raw HTTPResponse. In our current implementation is this not possible. This opens up the API to access the HTTPResponse when needed.
Make sure to check all boxes before merging