[AWS] Patch for Client Cookie Support
Pascal Obry
p.obry@wanadoo.fr
Mon, 17 Sep 2001 21:01:59 +0200
Here is the patch to add client cookie support in AWS. This patch has not been
tested. It should apply fine on AWS 1.0, it is posted here in the hope that it
could be useful. Support for Client Cookie will be available on AWS 1.1 (not
yet released).
<<
Index: aws-client.adb
===================================================================
RCS file: r:/./AWS/src/aws-client.adb,v
retrieving revision 1.26
retrieving revision 1.27
diff -c -r1.26 -r1.27
*** aws-client.adb 2001/06/23 15:59:47 1.26
--- aws-client.adb 2001/08/19 16:16:10 1.27
***************
*** 62,68 ****
Content_Type : out Unbounded_String;
Transfer_Encoding : out Unbounded_String;
Location : out Unbounded_String;
! Connection : out Unbounded_String);
-- Read server answer and set corresponding variable with the value
-- read. Most of the fields are ignored right now.
--- 62,69 ----
Content_Type : out Unbounded_String;
Transfer_Encoding : out Unbounded_String;
Location : out Unbounded_String;
! Connection : out Unbounded_String;
! Cookie : out Unbounded_String);
-- Read server answer and set corresponding variable with the value
-- read. Most of the fields are ignored right now.
***************
*** 235,241 ****
begin
! Parse_Header (Sock, Status, CT_Len, CT, TE, Location, Connect);
-- check for special status
--- 236,243 ----
begin
! Parse_Header
! (Sock, Status, CT_Len, CT, TE, Location, Connect, Connection.Cookie);
-- check for special status
***************
*** 308,313 ****
--- 310,316 ----
end;
end if;
end if;
+
Disconnect;
end Get_Response;
***************
*** 373,379 ****
Content_Type : out Unbounded_String;
Transfer_Encoding : out Unbounded_String;
Location : out Unbounded_String;
! Connection : out Unbounded_String) is
begin
Content_Length := 0;
--- 376,383 ----
Content_Type : out Unbounded_String;
Transfer_Encoding : out Unbounded_String;
Location : out Unbounded_String;
! Connection : out Unbounded_String;
! Cookie : out Unbounded_String) is
begin
Content_Length := 0;
***************
*** 420,425 ****
--- 424,433 ----
(Line (Messages.Proxy_Connection_Token'Last + 1 .. Line'
Last));
+ elsif Messages.Is_Match (Line, Messages.Set_Cookie_Token) then
+ Cookie := To_Unbounded_String
+ (Line (Messages.Set_Cookie_Token'Last + 1 .. Line'Last));
+
else
-- everything else is ignore right now
null;
***************
*** 630,635 ****
--- 638,648 ----
end if;
+ if Connection.Cookie /= Null_Unbounded_String then
+ Sockets.Put_Line
+ (Sock, Messages.Cookie_Token & To_String (Connection.Cookie));
+ end if;
+
-- Sockets.Put_Line (Sock, "Pragma: no-cache");
Sockets.Put_Line (Sock, Messages.Host (Host_Address));
Sockets.Put_Line (Sock, Messages.Accept_Type ("text/html, */*"));
***************
*** 703,708 ****
--- 716,722 ----
AWS.URL.Port (Connect_URL),
AWS.URL.Security (Connect_URL))),
Retry => Create.Retry,
+ Cookie => Null_Unbounded_String,
Persistent => Persistent);
end Create;
***************
*** 883,889 ****
-- get answer from server
! Parse_Header (Sock, Status, CT_Len, CT, TE, Location, Connect);
if Messages.Is_Match (To_String (Connect), "close") then
Disconnect (Connection);
--- 897,904 ----
-- get answer from server
! Parse_Header (Sock, Status, CT_Len, CT, TE,
! Location, Connect, Connection.Cookie);
if Messages.Is_Match (To_String (Connect), "close") then
Disconnect (Connection);
Index: aws-client.ads
===================================================================
RCS file: r:/./AWS/src/aws-client.ads,v
retrieving revision 1.10
retrieving revision 1.11
diff -c -r1.10 -r1.11
*** aws-client.ads 2001/06/30 10:25:43 1.10
--- aws-client.ads 2001/08/19 16:16:05 1.11
***************
*** 184,189 ****
--- 184,190 ----
Proxy_Pwd : Unbounded_String;
Opened : Boolean;
Persistent : Boolean;
+ Cookie : Unbounded_String;
Socket : Socket_Access;
Retry : Positive;
end record;
Index: aws-messages.ads
===================================================================
RCS file: r:/./AWS/src/aws-messages.ads,v
retrieving revision 1.15
retrieving revision 1.16
diff -c -r1.15 -r1.16
*** aws-messages.ads 2001/06/23 15:59:40 1.15
--- aws-messages.ads 2001/08/19 16:16:00 1.16
***************
*** 89,94 ****
--- 89,97 ----
Cookie_Token : constant String := "Cookie: ";
subtype Cookie_Range is Positive range Cookie_Token'Range;
+
+ Set_Cookie_Token : constant String := "Set-Cookie: ";
+ subtype Set_Cookie_Range is Positive range Set_Cookie_Token'Range;
User_Agent_Token : constant String := "User-Agent: ";
subtype User_Agent_Range is Positive range User_Agent_Token'Range;
>>
AWS Team.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"