Skip to content

Commit

Permalink
URLRequestFactory Update
Browse files Browse the repository at this point in the history
- Ensure that URLRequest contents of httpBodyStream is copied to httpBody
  • Loading branch information
depoon committed Jan 3, 2019
1 parent b30015b commit ede0969
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion NetworkInterceptor.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "NetworkInterceptor"
s.version = "0.0.7"
s.version = "0.0.8"
s.swift_version = '4.2'
s.summary = "Intercepting Network Requests"
s.description = <<-DESC
Expand Down
8 changes: 7 additions & 1 deletion NetworkInterceptor/Source/Helpers/URLRequestFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import URLRequest_cURL

class URLRequestFactory {

Expand All @@ -16,7 +17,12 @@ class URLRequestFactory {
urlString = "\(urlString)?\(query)"
}
var redirectedRequest = URLRequest(url: URL(string: urlString)!)
redirectedRequest.httpBody = originalUrlRequest.httpBody
if let _ = originalUrlRequest.httpBodyStream,
let httpBodyStreamData = originalUrlRequest.getHttpBodyStreamData() {
redirectedRequest.httpBody = httpBodyStreamData
} else {
redirectedRequest.httpBody = originalUrlRequest.httpBody
}
redirectedRequest.httpMethod = originalUrlRequest.httpMethod!
redirectedRequest.allHTTPHeaderFields = originalUrlRequest.allHTTPHeaderFields
redirectedRequest.cachePolicy = originalUrlRequest.cachePolicy
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- GzipSwift (4.0.4)
- URLRequest-cURL (0.0.2):
- URLRequest-cURL (0.0.3):
- GzipSwift

DEPENDENCIES:
Expand All @@ -14,7 +14,7 @@ SPEC REPOS:

SPEC CHECKSUMS:
GzipSwift: 1a5bc5f7827e09846b0635b5079f1224bc3b1c3a
URLRequest-cURL: b366c9bb861b6e569c81ff96088cbecacc987ac6
URLRequest-cURL: b159525e416ead3133ae60450660b8c82d2f2aa0

PODFILE CHECKSUM: 705ea690507f6390f795ead03efbad69830e36d4

Expand Down

0 comments on commit ede0969

Please sign in to comment.