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

Add info for debugDescription #2700

Merged
merged 3 commits into from Mar 7, 2019

Conversation

Projects
None yet
3 participants
@rain2540
Copy link
Contributor

rain2540 commented Jan 23, 2019

add parameters info for debugDescription of DataResponse and DownloadResponse

feat (Response) : add info for debugDescription
add parameters info for debugDescription of DataResponse and DownloadResponse
@jshier
Copy link
Contributor

jshier left a comment

Thanks for the PR! Sorry it's taken so long, but we definitely want these changes. I end up writing this manually a lot. You can make the code a lot simpler with my suggestions and I think we should print the response body as well.

@@ -88,6 +88,12 @@ extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible {
/// result.
public var debugDescription: String {
let requestDescription = request.map { "\($0.httpMethod!) \($0)" } ?? "nil"
let parameters = { () -> String in

This comment has been minimized.

@jshier

jshier Mar 6, 2019

Contributor

You can greatly compact this code, and the naming should reflect the fact that it's the body parameters:

let body = request?.httpBody.map { String(decoding: $0, as: UTF8.self) } ?? "None"
...
[Request Body]: \(body)

This comment has been minimized.

@rain2540

rain2540 Mar 6, 2019

Author Contributor

Thank you for your suggestion

@@ -101,6 +107,7 @@ extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible {

return """
[Request]: \(requestDescription)
[Parameters]: \(parameters)
[Response]: \n\(responseDescription)
[Data]: \(data?.description ?? "None")

This comment has been minimized.

@jshier

jshier Mar 6, 2019

Contributor

Since you're adding the "Request Body", you should do the same thing here: generate a String from the response Data and update this field to be [Response Body].

This comment has been minimized.

@rain2540

rain2540 Mar 7, 2019

Author Contributor

I have added [Response Body]

@@ -272,6 +279,12 @@ extension DownloadResponse: CustomStringConvertible, CustomDebugStringConvertibl
/// actions, and the response serialization result.
public var debugDescription: String {
let requestDescription = request.map { "\($0.httpMethod!) \($0)" } ?? "nil"
let parameters = { () -> String in

This comment has been minimized.

@jshier

jshier Mar 6, 2019

Contributor

Same changes as mentioned earlier.

rain2540 added some commits Mar 6, 2019

@jshier

jshier approved these changes Mar 7, 2019

Copy link
Contributor

jshier left a comment

Looks good, thanks!

@jshier jshier added this to the 5.X milestone Mar 7, 2019

@jshier jshier merged commit dd8eff7 into Alamofire:master Mar 7, 2019

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@jshier jshier modified the milestones: 5.X, 5.0.0-beta.3 Mar 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.