Skip to content

Commit 49c1587

Browse files
committed
Properly initialize the connection object based on settings.
Part of S507-051.
1 parent 329654a commit 49c1587

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/core/aws-client-http_utils.adb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ package body AWS.Client.HTTP_Utils is
138138
procedure Send_H2_Connection_Preface
139139
(Connection : in out HTTP_Connection;
140140
Settings : HTTP2.Frame.Settings.Set;
141-
H_Connection : HTTP2.Connection.Object)
141+
H_Connection : in out HTTP2.Connection.Object)
142142
with Pre => not Connection.H2_Preface_Sent;
143143
-- Send connection preface and get response from server
144144

@@ -630,6 +630,10 @@ package body AWS.Client.HTTP_Utils is
630630
Dec_Table'Access,
631631
H_Connection'Access);
632632
begin
633+
-- Set default connection settings
634+
635+
HTTP2.Connection.Set (H_Connection, Settings);
636+
633637
-- Create the request HTTP/2 message out of Status.Data
634638

635639
if Data'Length > 0 then
@@ -640,6 +644,7 @@ package body AWS.Client.HTTP_Utils is
640644
end if;
641645

642646
if not Connection.H2_Preface_Sent then
647+
-- Update H_Connection with server settings
643648
Send_H2_Connection_Preface (Connection, Settings, H_Connection);
644649
end if;
645650

@@ -981,6 +986,10 @@ package body AWS.Client.HTTP_Utils is
981986

982987
Build_Root_Part_Header;
983988

989+
-- Set default connection settings
990+
991+
HTTP2.Connection.Set (H_Connection, Settings);
992+
984993
Retry : loop
985994
begin
986995
Set_Common_Post
@@ -1003,6 +1012,7 @@ package body AWS.Client.HTTP_Utils is
10031012
end if;
10041013

10051014
if not Connection.H2_Preface_Sent then
1015+
-- Update H_Connection with server settings
10061016
Send_H2_Connection_Preface (Connection, Settings, H_Connection);
10071017
end if;
10081018

@@ -1859,7 +1869,7 @@ package body AWS.Client.HTTP_Utils is
18591869
procedure Send_H2_Connection_Preface
18601870
(Connection : in out HTTP_Connection;
18611871
Settings : HTTP2.Frame.Settings.Set;
1862-
H_Connection : HTTP2.Connection.Object)
1872+
H_Connection : in out HTTP2.Connection.Object)
18631873
is
18641874
use all type HTTP2.Frame.Kind_Type;
18651875
begin
@@ -1882,6 +1892,20 @@ package body AWS.Client.HTTP_Utils is
18821892
if Frame.Kind /= K_Settings then
18831893
raise Constraint_Error with
18841894
"server should have answered with a setting frame";
1895+
1896+
else
1897+
declare
1898+
S_Frame : constant HTTP2.Frame.Settings.Object :=
1899+
HTTP2.Frame.Settings.Object (Frame);
1900+
begin
1901+
-- Make sure the settings frame is not an aknowledged, this
1902+
-- should not happen anyway.
1903+
1904+
if not S_Frame.Has_Flag (HTTP2.Frame.Ack_Flag) then
1905+
HTTP2.Connection.Set
1906+
(H_Connection, HTTP2.Frame.Settings.Values (S_Frame));
1907+
end if;
1908+
end;
18851909
end if;
18861910
end;
18871911

0 commit comments

Comments
 (0)