----------------------------------------------------------------------------- -- -- libwww-ada95 : A World Wide Web client library for Ada95 -- -- W W W . M E S S A G E -- -- S p e c -- -- Copyright (C) 1997-1998 Regents of the University of California -- -- libwww-ada95 is free software; you can redistribute it and/or modify it -- under the terms of the GNU General Public License as published by the Free -- Software Foundation, with or without the single exception listed below; -- either version 2, or (at your option) any later version. libwww-ada95 is -- distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -- PARTICULAR PURPOSE. See the GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- distributed with libwww-ada95; see the file COPYING. If not, write to the -- Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. -- -- As a special exception, if other files instantiate generics from this -- library, or you link this library with other files to produce an -- executable, this library does not by itself cause the resulting -- executable to be covered by the GNU General Public License. This -- exception does not however invalidate any other reasons why the -- executable file might be covered by the GNU General Public License. -- -- Created in 1997 by Kari Nies ----------------------------------------------------------------------------- with System; with Ada.Strings.Unbounded; with Util.Hashed_Mapping; pragma Elaborate (Util.Hashed_Mapping); with WWW.Value_Lists; with WWW.Field_Names; package WWW.Message is package UB_Strings renames Ada.Strings.Unbounded; subtype UB_String is UB_Strings.Unbounded_String; subtype Value_List is Value_Lists.List; type Message_Header is record Field_Name : UB_String; Values : Value_List; end record; package Hash_Table is new Util.Hashed_Mapping ( UB_String, -- key type UB_Strings."=", -- equality for keys Field_Names.Field_Name, -- bucket range Field_Names.Parse_Field_Name, -- hash function Message_Header); -- value type type Version_Record is record Major_Revision : NATURAL; Minor_Revision : NATURAL; end record; type Message_Object is tagged record -- protocol default HTTP/1.1 Protocol : UB_String := UB_Strings.To_Unbounded_String ("HTTP"); Version : Version_Record := (1, 1); Message_Headers : Hash_Table.Mapping := Hash_Table.Create; Message_Body : System.Address := System.Null_Address; -- eventually change to Protocol_Stream end record; ---------------------------------------------------------------- -- insert header into the message object -- if header with given field name already exists, append the -- value [list] to the existing header -- resets Values to empty ---------------------------------------------------------------- procedure Insert_Header (Message : in out Message_Object; Field_Name : UB_String; Values : in out Value_List); procedure Insert_Header (Message : in out Message_Object; Field_Name : STRING; Values : in out Value_List); procedure Insert_Header (Message : in out Message_Object; Field_Name : UB_String; Value : UB_String); procedure Insert_Header (Message : in out Message_Object; Field_Name : STRING; Value : STRING); ---------------------------------------------------------------- -- returns a list of values associated with the given field name ---------------------------------------------------------------- function Get_Value_List (Message : Message_Object; Field_Name : UB_String) return Value_List; function Get_Value_List (Message : Message_Object; Field_Name : STRING) return Value_List; ---------------------------------------------------------------- -- returns a ordered, concatenated, comma-separated string of all -- values associated with the given field name ---------------------------------------------------------------- function Get_Header_Value_String (Message : Message_Object; Field_Name : UB_String) return UB_String; function Get_Header_Value_String (Message : Message_Object; Field_Name : STRING) return UB_String; -- Image returns a readable string for the Version (e.g., "1.1") -- function Image (Version : Version_Record) return String; -- Raised by Get_Header_List and Get_Header_Value_String if -- the given Field_Name is not in the message header table Invalid_Field_Name : exception; procedure Print_Message (Message : Message_Object); end WWW.Message;