Skip to content

Commit

Permalink
Update to ponylang/http 0.6.0 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen authored Jan 21, 2024
1 parent ef5bdc1 commit e53a338
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .release-notes/http-0.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Update to ponylang/http 0.6.0

We've updated our `ponylang/http` dependency to 0.6.0. This includes a fix that will allow correct operation when using OpenSSL 3.2.
2 changes: 1 addition & 1 deletion corral.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"locator": "github.com/ponylang/http.git",
"version": "0.5.4"
"version": "0.6.0"
},
{
"locator": "github.com/ponylang/json.git",
Expand Down
9 changes: 4 additions & 5 deletions github_rest_api/paginated_list.pony
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,19 @@ actor PaginatedResultReceiver[A: Any val]
// TODO: Could this be more generic?
class PaginatedJsonRequester
let _auth: TCPConnectAuth
let _client: HTTPClient
let _sslctx: (SSLContext | None)

new create(auth: TCPConnectAuth) =>
_auth = auth

let sslctx = try
_sslctx = try
recover val
SSLContext.>set_client_verify(true).>set_authority(None)?
end
else
None
end

_client = HTTPClient(_auth, sslctx)

fun ref apply[A: Any val](url: String,
receiver: PaginatedResultReceiver[A]) ?
=>
Expand All @@ -155,7 +153,8 @@ class PaginatedJsonRequester

let handler_factory =
PaginatedJsonRequesterHandlerFactory[A](_auth, receiver)
_client(consume r, handler_factory)?
let client = HTTPClient(_auth, handler_factory, _sslctx)
client(consume r)?

class PaginatedJsonRequesterHandlerFactory[A: Any val] is HandlerFactory
let _auth: TCPConnectAuth
Expand Down
12 changes: 7 additions & 5 deletions github_rest_api/request/http_delete.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ interface tag DeleteResultReceiver
be failure(status: U16, response_body: String, message: String)

class HTTPDelete
let _client: HTTPClient
let _auth: TCPConnectAuth
let _sslctx: (SSLContext | None)

new create(auth: TCPConnectAuth) =>
let sslctx = try
_auth = auth

_sslctx = try
recover val
SSLContext.>set_client_verify(true).>set_authority(None)?
end
else
None
end

_client = HTTPClient(auth, sslctx)

fun ref apply(url: String,
receiver: DeleteResultReceiver,
auth_token: (String | None) = None) ?
Expand All @@ -29,7 +30,8 @@ class HTTPDelete
let r = RequestFactory("DELETE", valid_url, auth_token)

let handler_factory = HTTPDeleteHandlerFactory(receiver)
_client(consume r, handler_factory)?
let client = HTTPClient(_auth, handler_factory, _sslctx)
client(consume r)?

class HTTPDeleteHandlerFactory is HandlerFactory
let _receiver: DeleteResultReceiver
Expand Down
9 changes: 4 additions & 5 deletions github_rest_api/request/http_get.pony
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@ use "promises"

class JsonRequester
let _auth: TCPConnectAuth
let _client: HTTPClient
let _sslctx: (SSLContext | None)

new create(auth: TCPConnectAuth) =>
_auth = auth

let sslctx = try
_sslctx = try
recover val
SSLContext.>set_client_verify(true).>set_authority(None)?
end
else
None
end

_client = HTTPClient(_auth, sslctx)

fun ref apply(url: String,
receiver: JsonRequesterResultReceiver) ?
=>
let valid_url = URL.valid(url)?
let r = RequestFactory("GET", valid_url)

let handler_factory = JsonRequesterHandlerFactory(_auth, receiver)
_client(consume r, handler_factory)?
let client = HTTPClient(_auth, handler_factory, _sslctx)
client(consume r)?

interface tag JsonRequesterResultReceiver
be success(json: JsonDoc val)
Expand Down
12 changes: 7 additions & 5 deletions github_rest_api/request/http_post.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ interface tag PostResultReceiver
be failure(status: U16, response_body: String, message: String)

class HTTPPost
let _client: HTTPClient
let _auth: TCPConnectAuth
let _sslctx: (SSLContext | None)

new create(auth: TCPConnectAuth) =>
let sslctx = try
_auth = auth

_sslctx = try
recover val
SSLContext.>set_client_verify(true).>set_authority(None)?
end
else
None
end

_client = HTTPClient(auth, sslctx)

fun ref apply(url: String,
body: String,
receiver: PostResultReceiver,
Expand All @@ -31,7 +32,8 @@ class HTTPPost
r.add_chunk(body)

let handler_factory = HTTPPostHandlerFactory(receiver)
_client(consume r, handler_factory)?
let client = HTTPClient(_auth, handler_factory, _sslctx)
client(consume r)?

class HTTPPostHandlerFactory is HandlerFactory
let _receiver: PostResultReceiver
Expand Down

0 comments on commit e53a338

Please sign in to comment.