Skip to content

Commit aa0e48c

Browse files
committed
[okhttp] Update okhttp version
1 parent c2f797d commit aa0e48c

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ext {
44

55
json: '20240303', // org.json:json
66
snakeyaml: '1.33', // org.yaml:snakeyaml
7-
okhttp: '3.14.9', // com.squareup.okhttp3:okhttp
7+
okhttp: '4.12.0', // com.squareup.okhttp3:okhttp
88
socket: '2.1.0', // io.socket:socket.io-client
99
jline: '2.14.6', // jline:jline
1010

docs/docs/en/changelog.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
## Next
44

55
### Fixes
6-
- Fix passing command-line arguments to scripts
7-
- Fix `this` in non-static class methods
6+
- Fix passing command-line arguments to scripts.
7+
- Fix `this` in non-static class methods.
8+
- Fix program stucking if using any http call (okhttp issue).
89

910
### Modules
10-
- [okhttp] Added `okhttp.newClient()` and `HttpClientBuilderValue`
11+
- [okhttp] Added `okhttp.newClient()` and `HttpClientBuilderValue`.
1112

1213

1314
## 2.0.0

modules/main/src/main/java/com/annimon/ownlang/modules/http/HttpFunctions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ private RequestBody getStringRequestBody(Value params, MapValue options) throws
177177

178178
if (options.containsKey(CHARSET_KEY)) {
179179
final String charset = options.get(CHARSET_KEY).asString();
180-
return RequestBody.create(type, params.asString().getBytes(charset));
180+
return RequestBody.create(params.asString().getBytes(charset), type);
181181
}
182182

183-
return RequestBody.create(type, params.asString());
183+
return RequestBody.create(params.asString(), type);
184184
}
185185
}

modules/main/src/main/java/com/annimon/ownlang/modules/okhttp/okhttp.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,23 @@ private static MapValue requestBody() {
5252
bytesCount = args[3].asInt();
5353
}
5454
return new RequestBodyValue(RequestBody.create(
55+
bytes,
5556
MediaType.parse(args[0].asString()),
56-
bytes, offset, bytesCount
57+
offset, bytesCount
5758
));
5859
});
5960
requestBody.set("file", args -> {
6061
Arguments.check(2, args.length);
6162
return new RequestBodyValue(RequestBody.create(
62-
MediaType.parse(args[0].asString()),
63-
Console.fileInstance(args[1].asString())
63+
Console.fileInstance(args[1].asString()),
64+
MediaType.parse(args[0].asString())
6465
));
6566
});
6667
requestBody.set("string", args -> {
6768
Arguments.check(2, args.length);
6869
return new RequestBodyValue(RequestBody.create(
69-
MediaType.parse(args[0].asString()),
70-
args[1].asString()
70+
args[1].asString(),
71+
MediaType.parse(args[0].asString())
7172
));
7273
});
7374
return requestBody;

0 commit comments

Comments
 (0)