-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Status Code is not shown #58
Comments
Looks like a defect. Can you share how you logs the network requests, please? |
struct NetworkLoggerEventMonitor: EventMonitor {
let logger: NetworkLogger
func request(_ request: Request, didCreateTask task: URLSessionTask) {
logger.logTaskCreated(task)
}
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
logger.logDataTask(dataTask, didReceive: data)
}
func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
logger.logTask(task, didFinishCollecting: metrics)
}
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
logger.logTask(task, didCompleteWithError: error)
}
}
class APIManager {
let logger = NetworkLogger()
static let shared = APIManager()
let manager: Alamofire.Session
init() {
let configure = URLSessionConfiguration.default
configure.timeoutIntervalForRequest = 40
configure.timeoutIntervalForResource = 40
manager = Alamofire.Session(configuration: configure, eventMonitors: [NetworkLoggerEventMonitor(logger: logger)])
}
} I am using
func request<T: Codable>(encoding: ParameterEncoding = JSONEncoding.default) -> Single<T> {
return Single<T>.create { observer in
let request = manager.request(
endPoint,
method: method,
parameters: self.parameters,
encoding: encoding,
headers: headerAuthorization
)
request
.handleCodable { (response: ResponseContainer<T>) in
guard let isReachable = NetworkReachabilityManager()?.isReachable,
isReachable
else {
let error = NSError(
domain: "NETWORK_REACHABILITY_DOMAIN",
code: -99,
message: "Network is invalid"
)
return observer(.failure(error))
}
if let data = response.data {
observer(.success(data))
}
} failure: { error in
observer(.failure(error))
}
return Disposables.create {
request.cancel()
}
}
} |
Looks like this issue is specific to the public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
...
} I missed it when I wrote an example of Fortunately, it's not required. I'm going to ship a fix in today's release. |
Fixed in 0.20.0 |
Now, it's working great! |
Pulse looks like it is such an amazing network logger, but
PulseUI
does not showstatus code
.I am using
Alamofire
for networking.This red circle's supposed to be
fail
because the network response code returns401
.However, it is shown as
Success
.This image is a detailed page of
above image
which returnsstatus code
as401
.As image shown,
Status Code
displays as-
.Is there any parts that I am missing?
Thank you.
The text was updated successfully, but these errors were encountered: