Skip to content

Commit

Permalink
Add support for request and response haeders in task cell header
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 14, 2024
1 parent 59ae038 commit 02fc0cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
public var id: URLComponent { self }
}

public enum TaskField: Sendable, Codable, Hashable, Identifiable, CaseIterable {
public enum TaskField: Sendable, Codable, Hashable, Identifiable {
case method
case requestSize
case responseSize
case responseContentType
case duration
case host
case statusCode
/// The type of the task, e.g. "Data" or "Download"
case taskType
/// The `taskDescription` value of `URLSessionTask`.
case taskDescription
case requestHeaderField(key: String)
case responseHeaderField(key: String)

public var id: TaskField { self }

Expand All @@ -91,6 +91,8 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
case .statusCode: "Status Code"
case .taskType: "Task Type"
case .taskDescription: "Task Description"
case .requestHeaderField(let key): "Request Header \"\(key)\""
case .responseHeaderField(let key): "Response Header '\(key)\""
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/PulseUI/Features/Console/Views/ConsoleTaskCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ private extension NetworkTaskEntity {
NetworkLogger.TaskType(rawValue: taskType)?.urlSessionTaskClassName
case .taskDescription:
taskDescription
case .requestHeaderField(let key):
(currentRequest?.headers ?? [:])[key]
case .responseHeaderField(let key):
(response?.headers ?? [:])[key]
}
}

Expand Down

0 comments on commit 02fc0cd

Please sign in to comment.