Skip to content
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

Merged
merged 18 commits into from Aug 1, 2017
Merged

Conversation

lightsprint09
Copy link
Member

@lightsprint09 lightsprint09 commented Jun 13, 2017

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

  • Method/Class documentation
  • README.md documentation
  • Unit tests for new features/regressions

@@ -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)

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)

@dennispost
Copy link
Member

@lightsprint09 I'm missing a description of the PR goals

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing httpResponse parameter doc

@@ -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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing function documentation

Copy link
Member Author

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
Copy link

codecov bot commented Jul 7, 2017

Codecov Report

Merging #41 into develop will increase coverage by 0.86%.
The diff coverage is 93.1%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
Source/RetryNetworkTask.swift 88.23% <ø> (ø) ⬆️
Source/URLRequestConvertible.swift 82.6% <0%> (ø) ⬆️
Source/RetryNetworkService.swift 89.47% <100%> (+0.58%) ⬆️
Source/NetworkServiceMock.swift 87.5% <100%> (ø) ⬆️
Source/NetworkService.swift 100% <100%> (ø) ⬆️
Source/ModifyRequestNetworkService.swift 94.11% <100%> (ø) ⬆️
Source/NetworkServiceProviding.swift 100% <100%> (ø) ⬆️
Source/NetworkResponseProcessor.swift 96.96% <88.88%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c727a7c...0c4ebda. Read the comment docs.

import Foundation

extension URL {
static let defaultMock: URL = URL(string: "bahn.de")!

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")!

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")!

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)

}, 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())

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)

}, 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())

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)

}, 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())

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)

Copy link
Collaborator

@ch-one ch-one left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbBetworkError => dbNetworkError

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦇 -Work??

@@ -33,11 +33,11 @@ import Dispatch
*/
public protocol NetworkServiceProviding {
/**
Fetches a resource asynchrony from remote location
Fetches a resource asynchrony from remote location.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean 'asynchronously'?

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@@ -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.

Copy link
Member

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

@lightsprint09 lightsprint09 merged commit 0d18f5b into develop Aug 1, 2017
@lightsprint09 lightsprint09 deleted the feature/access-http-response branch August 1, 2017 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants