From 5839ee8f604d015329b5f29083dee0ff124dd111 Mon Sep 17 00:00:00 2001 From: Shane Howley Date: Wed, 8 Jul 2026 19:36:57 +0100 Subject: [PATCH] Support hackney v4 in EventStream --- lib/ex_aws/bedrock/event_stream.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ex_aws/bedrock/event_stream.ex b/lib/ex_aws/bedrock/event_stream.ex index 80e80df..1816499 100644 --- a/lib/ex_aws/bedrock/event_stream.ex +++ b/lib/ex_aws/bedrock/event_stream.ex @@ -18,7 +18,13 @@ defmodule ExAws.Bedrock.EventStream do if {:module, :hackney} == Code.ensure_loaded(:hackney) && Kernel.function_exported?(:hackney, :post, 4) do - @http_ua :hackney_request.default_ua() + # hackney >= 4 moved default_ua/0 from :hackney_request to :hackney + if function_exported?(:hackney, :default_ua, 0) do + @http_ua :hackney.default_ua() + else + @http_ua :hackney_request.default_ua() + end + @library_version Application.spec(:ex_aws_bedrock)[:vsn] @user_agent "#{@http_ua} ex_aws/bedrock/#{@library_version}" @headers [