Skip to content

Commit

Permalink
Simplify code by using To_Lower as in pure HTTP/2 unit.
Browse files Browse the repository at this point in the history
Part of S507-051.
  • Loading branch information
TurboGit committed Oct 5, 2021
1 parent 1295663 commit 36373d7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/http2/aws-http2-message.adb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
------------------------------------------------------------------------------

with Ada.Calendar;
with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

Expand All @@ -45,11 +46,8 @@ package body AWS.HTTP2.Message is

use Ada.Strings.Unbounded;

function HN
(Header_Name : String;
Is_H2 : Boolean := True)
return String renames Utils.Normalize_Lower;
-- Fold header name to lower case as required by HTTP/2 protocol
function To_Lower
(Name : String) return String renames Ada.Characters.Handling.To_Lower;

-----------------
-- Append_Body --
Expand Down Expand Up @@ -127,7 +125,7 @@ package body AWS.HTTP2.Message is

if Size /= Resources.Undefined_Length then
O.Headers.Add
(HN (Messages.Content_Length_Token), Utils.Image (Size));
(To_Lower (Messages.Content_Length_Token), Utils.Image (Size));
end if;
end Set_Body;

Expand All @@ -143,7 +141,7 @@ package body AWS.HTTP2.Message is
-- Set status code

O.Headers.Add
(HN (Messages.Status_Token),
(To_Lower (Messages.Status_Token),
Messages.Image (Response.Status_Code (Answer)));

if O.Mode /= Response.Header then
Expand Down Expand Up @@ -197,7 +195,7 @@ package body AWS.HTTP2.Message is
(Answer, Messages.Last_Modified_Token)
then
O.Headers.Add
(HN (Messages.Last_Modified_Token),
(To_Lower (Messages.Last_Modified_Token),
Messages.To_HTTP_Date (File_Time));
end if;

Expand Down Expand Up @@ -374,7 +372,8 @@ package body AWS.HTTP2.Message is
begin
if Size /= Resources.Undefined_Length then
Self.Headers.Add
(HN (Messages.Content_Length_Token), Utils.Image (Size));
(To_Lower (Messages.Content_Length_Token),
Utils.Image (Size));
end if;
end;
end if;
Expand Down

0 comments on commit 36373d7

Please sign in to comment.