@@ -67,22 +67,30 @@ request.httpBody = try! multipartFormData.encode()
67
67
""" ;
68
68
69
69
final String kTemplateEnd = """
70
+ let semaphore = DispatchSemaphore(value: 0)
71
+
70
72
let task = URLSession.shared.dataTask(with: request) { data, response, error in
73
+ defer { semaphore.signal() }
74
+
71
75
if let error = error {
72
- print("Error: (error.localizedDescription)")
76
+ print("Error: \\ (error.localizedDescription)")
73
77
return
74
78
}
75
79
guard let data = data else {
76
80
print("No data received")
77
81
return
78
82
}
79
83
if let responseString = String(data: data, encoding: .utf8) {
80
- print("Response: (responseString)")
84
+ print("Response: \\ (responseString)")
81
85
}
82
86
}
87
+
83
88
task.resume()
89
+
90
+ semaphore.wait()
84
91
""" ;
85
92
93
+
86
94
String ? getCode (HttpRequestModel requestModel) {
87
95
try {
88
96
String result = kTemplateStart;
@@ -145,7 +153,7 @@ task.resume()
145
153
var headers = requestModel.enabledHeadersMap;
146
154
if (requestModel.hasFormData) {
147
155
headers.putIfAbsent ("Content-Type" ,
148
- () => "multipart/form-data; boundary=(boundary.stringValue)" );
156
+ () => "multipart/form-data; boundary=\\ (boundary.stringValue)" );
149
157
} else if (requestModel.hasJsonData || requestModel.hasTextData) {
150
158
headers.putIfAbsent (
151
159
kHeaderContentType, () => requestModel.bodyContentType.header);
0 commit comments