Skip to content

Commit

Permalink
Fix posting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWDG committed Jan 10, 2025
1 parent 146ec86 commit 0557109
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
10 changes: 0 additions & 10 deletions Sources/SimpleNetworking/SimpleNetworking/createHTTPBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ extension SimpleNetworking {
return nil
}

// Get post encoding
func getPostEncoding(data: Any?) -> POSTEncoding {
if let string = data as? String,
string.contains("{") && string.contains("}") {
return .json
}

return .plain
}

/// Content-Type Header for internal use
func getContentType(postType: POSTEncoding = .json) -> String {
switch postType {
Expand Down
5 changes: 2 additions & 3 deletions Sources/SimpleNetworking/SimpleNetworking/request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ extension SimpleNetworking {

switch method {
case .delete(let data), .post(let data), .patch(let data), .put(let data):
let newEncoding: POSTEncoding = getPostEncoding(data: data)
request.setValue(getContentType(postType: newEncoding), forHTTPHeaderField: "Content-Type")
request.httpBody = createHTTPBody(with: data, postType: newEncoding)
request.setValue(getContentType(postType: encoding), forHTTPHeaderField: "Content-Type")
request.httpBody = createHTTPBody(with: data, postType: encoding)

case .get:
break
Expand Down
1 change: 1 addition & 0 deletions Sources/SimpleNetworking/Structs/NetworkResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ extension SimpleNetworking {
return try decoder.decode(T.self, from: data)
} catch {
print("\(file):\(line) \(function):\r\nDecoding error", error)
print("Raw string: \"\(self.string ?? "")\".")
return nil
}
}
Expand Down

0 comments on commit 0557109

Please sign in to comment.