Skip to content

Commit

Permalink
Fix missing request body (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: Mehdi Mirzaei <[email protected]>
  • Loading branch information
mehdiimrz and Mehdi Mirzaei authored Nov 13, 2022
1 parent c5c9838 commit e850e9f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions Sources/NetShears/Extension/URLRequest+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extension URLRequest {
data.append(&buffer, length: length)
}
}
httpBodyStream.close()
return data as Data
}
}
3 changes: 1 addition & 2 deletions Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class NetworkLoggerUrlProtocol: URLProtocol {
/// The receiver will have either an HTTP body or an HTTP body stream only one may be set for a request.
/// A HTTP body stream is preserved when copying an NSURLRequest object,
/// but is lost when a request is archived using the NSCoding protocol.
// return request.httpBody ?? request.httpBodyStream?.readfully()
return nil
return request.httpBody ?? request.getHttpBodyStreamData()
}

deinit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class NetwrokListenerUrlProtocol: URLProtocol {
/// The receiver will have either an HTTP body or an HTTP body stream only one may be set for a request.
/// A HTTP body stream is preserved when copying an NSURLRequest object,
/// but is lost when a request is archived using the NSCoding protocol.
// return request.httpBody ?? request.httpBodyStream?.readfully()
return nil
return request.httpBody ?? request.getHttpBodyStreamData()
}

deinit {
Expand Down

0 comments on commit e850e9f

Please sign in to comment.