-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgnat-sockets-connection_state_machine-http_server.ads
2167 lines (2103 loc) · 68.7 KB
/
gnat-sockets-connection_state_machine-http_server.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- GNAT.Sockets.Connection_State_Machine. Luebeck --
-- HTTP_Server Winter, 2013 --
-- Interface --
-- Last revision : 20:46 27 Aug 2020 --
-- --
-- This library 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; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- 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 along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit 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 Public License. --
--____________________________________________________________________--
with Ada.Calendar; use Ada.Calendar;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Task_Identification; use Ada.Task_Identification;
with Strings_Edit.Time_Conversions; use Strings_Edit.Time_Conversions;
with Ada.Finalization;
with Ada.Containers.Ordered_Sets; -- Changed to use standard library by J. Carter 2021
with GNAT.Sockets.Connection_State_Machine.Expected_Sequence;
with GNAT.Sockets.Connection_State_Machine.Terminated_Strings;
with Stack_Storage;
with Tables.Names;
package GNAT.Sockets.Connection_State_Machine.HTTP_Server is
--
-- HTTP_Method -- Methods
--
type HTTP_Method is
( HTTP_GET,
HTTP_HEAD,
HTTP_POST,
HTTP_PUT,
HTTP_DELETE,
HTTP_TRACE,
HTTP_OPTIONS,
HTTP_CONNECT,
HTTP_PATCH
);
type HTTP_Allowed is array (HTTP_Method) of Boolean;
type HTTP_Version is delta 0.1 digits 6 range 1.0..1_000.0;
--
-- Scheme_Type -- Recognized schemes (RFC 3986). Permanentl, historic
-- and provisional schemas registered to 2017-09-13
--
type Scheme_Type is
( Aaa_Scheme,
Aaas_Scheme,
About_Scheme,
Acap_Scheme,
Acct_Scheme,
Acr_Scheme,
Adiumxtra_Scheme,
AFP_Scheme,
AFS_Scheme,
Aim_Scheme,
Appdata_Scheme,
APT_Scheme,
Attachment_Scheme,
Aw_Scheme,
Barion_Scheme,
Beshare_Scheme,
Bitcoin_Scheme,
Blob_Scheme,
Bolo_Scheme,
Browserext_Scheme,
Callto_Scheme,
Cap_Scheme,
Chrome_Scheme,
Chrome_Extension_Scheme,
Cid_Scheme,
Coap_Scheme,
Coap_Tcp_Scheme,
Coaps_Scheme,
Coaps_Tcp_Scheme,
Com_Eventbrite_Attendee_Scheme,
Content_Scheme,
Crid_Scheme,
CVS_Scheme,
Data_Scheme,
Dav_Scheme,
Diaspora_Scheme,
Dict_Scheme,
DIS_Scheme,
DLNA_Playcontainer_Scheme,
DLNA_Playsingle_Scheme,
DNS_Scheme,
DNTP_Scheme,
DTN_Scheme,
DVB_Scheme,
Ed2k_Scheme,
Example_Scheme,
Facetime_Scheme,
Fax_Scheme,
Feed_Scheme,
Feedready_Scheme,
File_Scheme,
Filesystem_Scheme,
Finger_Scheme,
Fish_Scheme,
FTP_Scheme,
Geo_Scheme,
Gg_Scheme,
Git_Scheme,
Gizmoproject_Scheme,
Go_Scheme,
Gopher_Scheme,
Graph_Scheme,
Gtalk_Scheme,
H323_Scheme,
Ham_Scheme,
HCP_Scheme,
HTTP_Scheme,
HTTPS_Scheme,
HXXP_Scheme,
HXXPS_Scheme,
Hydrazone_Scheme,
Iax_Scheme,
Icap_Scheme,
Icon_Scheme,
Im_Scheme,
Imap_Scheme,
Info_Scheme,
Iotdisco_Scheme,
IPN_Scheme,
IPP_Scheme,
IPPS_Scheme,
IRC_Scheme,
IRC6_Scheme,
IRCS_Scheme,
Iris_Scheme,
Iris_Beep_Scheme,
Iris_LWZ_Scheme,
Iris_XPC_Scheme,
Iris_XPCS_Scheme,
Isostore_Scheme,
ITMS_Scheme,
Jabber_Scheme,
Jar_Scheme,
Jms_Scheme,
Keyparc_Scheme,
Lastfm_Scheme,
LDAP_Scheme,
LDAPS_Scheme,
LVLT_Scheme,
Magnet_Scheme,
Mailserver_Scheme,
Mailto_Scheme,
Maps_Scheme,
Market_Scheme,
Message_Scheme,
Mid_Scheme,
MMS_Scheme,
Modem_Scheme,
Mongodb_Scheme,
MOZ_Scheme,
MS_Access_Scheme,
MS_Browser_Extension_Scheme,
MS_Drive_To_Scheme,
MS_Enrollment_Scheme,
MS_Excel_Scheme,
MS_Gamebarservices_Scheme,
MS_Getoffice_Scheme,
MS_Help_Scheme,
MS_Infopath_Scheme,
MS_Inputapp_Scheme,
MS_Media_Stream_ID_Scheme,
MS_Officeapp_Scheme,
MS_People_Scheme,
MS_Project_Scheme,
MS_Powerpoint_Scheme,
MS_Publisher_Scheme,
MS_Search_Repair_Scheme,
MS_Secondary_Screen_Controller_Scheme,
MS_Secondary_Screen_Setup_Scheme,
MS_Settings_Scheme,
MS_Settings_Airplanemode_Scheme,
MS_Settings_Bluetooth_Scheme,
MS_Settings_Camera_Scheme,
MS_Settings_Cellular_Scheme,
MS_Settings_Cloudstorage_Scheme,
MS_Settings_Connectabledevices_Scheme,
MS_Settings_Displays_Topology_Scheme,
MS_Settings_Emailandaccounts_Scheme,
MS_Settings_Language_Scheme,
MS_Settings_Location_Scheme,
MS_Settings_Lock_Scheme,
MS_Settings_Nfctransactions_Scheme,
MS_Settings_Notifications_Scheme,
MS_Settings_Power_Scheme,
MS_Settings_Privacy_Scheme,
MS_Settings_Proximity_Scheme,
MS_Settings_Screenrotation_Scheme,
MS_Settings_WiFi_Scheme,
MS_Settings_Workplace_Scheme,
MS_SPD_Scheme,
MS_Sttoverlay_Scheme,
MS_Transit_To_Scheme,
MS_Virtualtouchpad_Scheme,
MS_Visio_Scheme,
MS_Walk_To_Scheme,
MS_Whiteboard_Scheme,
MS_Whiteboard_CMD_Scheme,
MS_Word_Scheme,
MSnim_Scheme,
MSRP_Scheme,
MSRPS_Scheme,
MTQP_Scheme,
Mumble_Scheme,
Mupdate_Scheme,
MVN_Scheme,
News_Scheme,
NFS_Scheme,
NI_Scheme,
NIH_Scheme,
NNTP_Scheme,
Notes_Scheme,
OCF_Scheme,
OID_Scheme,
Onenote_Scheme,
Onenote_CMD_Scheme,
Opaquelocktoken_Scheme,
Pack_Scheme,
Palm_Scheme,
Paparazzi_Scheme,
Pkcs11_Scheme,
Platform_Scheme,
POP_Scheme,
Pres_Scheme,
Prospero_Scheme,
Proxy_Scheme,
Pwid_Scheme,
Psyc_Scheme,
QB_Scheme,
Query_Scheme,
Redis_Scheme,
Rediss_Scheme,
Reload_Scheme,
Res_Scheme,
Resource_Scheme,
RMI_Scheme,
Rsync_Scheme,
RTMFP_Scheme,
RTMP_Scheme,
RTSP_Scheme,
RTSPS_Scheme,
RTSPU_Scheme,
Secondlife_Scheme,
Service_Scheme,
Session_Scheme,
SFTP_Scheme,
SGN_Scheme,
SHTTP_Scheme,
Sieve_Scheme,
Sip_Scheme,
Sips_Scheme,
Skype_Scheme,
SMB_Scheme,
SMS_Scheme,
SMTP_Scheme,
SNews_Scheme,
SNTP_Scheme,
Soap_Beep_Scheme,
Soap_Beeps_Scheme,
Soldat_Scheme,
Spotify_Scheme,
SSH_Scheme,
Steam_Scheme,
Stun_Scheme,
Stuns_Scheme,
Submit_Scheme,
SVN_Scheme,
Tag_Scheme,
Teamspeak_Scheme,
Tel_Scheme,
Teliaeid_Scheme,
Telnet_Scheme,
TFTP_Scheme,
Things_Scheme,
Thismessage_Scheme,
Tip_Scheme,
Tn3270_Scheme,
Tool_Scheme,
Turn_Scheme,
Turns_Scheme,
TV_Scheme,
UDP_Scheme,
Unreal_Scheme,
URN_Scheme,
UT2004_Scheme,
V_Event_Scheme,
VEMMI_Scheme,
Ventrilo_Scheme,
Videotex_Scheme,
VNC_Scheme,
View_Source_Scheme,
Wais_Scheme,
Webcal_Scheme,
Wpid_Scheme,
WS_Scheme,
WSS_Scheme,
WTAI_Scheme,
Wyciwyg_Scheme,
Xcon_Scheme,
Xcon_Userid_Scheme,
Xfire_Scheme,
XMLRPC_Beep_Scheme,
XMLRPC_Beeps_Scheme,
XMPP_Scheme,
XRI_Scheme,
YMSGR_Scheme,
Z39_50_Scheme,
Z39_50r_Scheme,
Z39_50s_Scheme,
Unknown_Scheme
);
--
-- Image -- Scheme name
--
-- Scheme - The scheme
--
-- Returns :
--
-- The corresponding name
--
function Image (Scheme : Scheme_Type) return String;
--
-- Request_Header -- Request header fields
--
type Request_Header is
( Accept_Header,
Accept_Charset_Header,
Accept_Encoding_Header,
Accept_Language_Header,
Accept_Datetime_Header,
Allow_Header,
Authorization_Header,
Cache_Control_Header,
Cookie_Header,
Content_Encoding_Header,
Content_Disposition_Header,
Content_Language_Header,
Content_Location_Header,
Content_MD5_Header,
Content_Type_Header,
Expect_Header,
Expires_Header,
From_Header,
Host_Header,
If_Match_Header,
If_None_Match_Header,
If_Range_Header,
Max_Forwards_Header,
Origin_Header,
Proxy_Authorization_Header,
Pragma_Header,
Referer_Header,
TE_Header,
Trailer_Header,
Transfer_Encoding_Header,
Upgrade_Header,
Upgrade_Insecure_Requests,
User_Agent_Header,
Via_Header,
Sec_WebSocket_Extensions_Header,
Sec_WebSocket_Protocol_Header,
Sec_WebSocket_Version_Header,
Sec_WebSocket_Key_Header,
X_Requested_By_Header, -- Non-standard text header
X_Requested_With_Header, -- Non-standard text header
X_XSRF_Token_Header, -- Non-standard text header
X_CSRF_Token_Header, -- Non-standard text header
Warning_Header,
Range_Header,
Connection_Header,
Content_Length_Header,
Date_Header,
If_Modified_Since_Header,
If_Unmodified_Since_Header,
Last_Modified_Header
);
--
-- Image -- Header name
--
-- Header - The header type
--
-- Returns :
--
-- The corresponding name, e.g. Keep-Alive
--
function Image (Header : Request_Header) return String;
--
-- Value -- String to header type conversion
--
-- Text - The header name (case-insensitive)
--
-- Returns :
--
-- The header type
--
type Header_Value (None : Boolean := True) is record
case None is
when True =>
null;
when False =>
Header : Request_Header;
end case;
end record;
function Value (Text : String) return Header_Value;
subtype Text_Header is Request_Header
range Accept_Header..Warning_Header;
subtype Multipart_Header is Request_Header
range Content_Encoding_Header..Content_Type_Header;
type WebSocket_Status is range 0..2**16 - 1;
--
-- Status codes in the range 0-999 are not used.
--
subtype WebSocket_Unused is WebSocket_Status range 0..999;
--
-- Status codes in the range 1000-2999 are reserved for definition by
-- this protocol, its future revisions, and extensions specified in a
-- permanent and readily available public specification.
--
subtype WebSocket_Mandated is WebSocket_Status range 1000..2999;
WebSocket_Normal_Closure : constant WebSocket_Mandated := 1000;
WebSocket_Endpoint_Shutdown : constant WebSocket_Mandated := 1001;
WebSocket_Protocol_Error : constant WebSocket_Mandated := 1002;
WebSocket_Type_Error : constant WebSocket_Mandated := 1003;
WebSocket_No_Status_Code : constant WebSocket_Mandated := 1005;
WebSocket_Aborted : constant WebSocket_Mandated := 1006;
WebSocket_Data_Error : constant WebSocket_Mandated := 1007;
WebSocket_Generic_Error : constant WebSocket_Mandated := 1008;
WebSocket_Constraint_Error : constant WebSocket_Mandated := 1009;
WebSocket_Not_Supported : constant WebSocket_Mandated := 1010;
WebSocket_Internal_Error : constant WebSocket_Mandated := 1011;
WebSocket_TLS_Error : constant WebSocket_Mandated := 1012;
--
-- Status codes in the range 3000-3999 are reserved for use by
-- libraries, frameworks, and applications. These status codes are
-- registered directly with IANA. The interpretation of these codes is
-- undefined by this protocol.
--
subtype WebSocket_IANA is WebSocket_Status range 3000..3999;
--
-- Status codes in the range 4000-4999 are reserved for private use and
-- thus can't be registered. Such codes can be used by prior agreements
-- between WebSocket applications. The interpretation of these codes is
-- undefined by this protocol.
--
subtype WebSocket_Private is WebSocket_Status range 4000..4999;
subtype WebSocket_Message_Size is Stream_Element_Count
range 125..Stream_Element_Count'Last;
--
-- Content_Ranges -- Ranges of content bytes
--
package Content_Ranges is new Ada.Containers.Ordered_Sets (Element_Type => Stream_Element_Count);
--
-- Range_Type -- Type of range
--
-- Explicit_Range - A range with both bounds specified
-- Suffix_Range - A range with unknown upper bound
--
type Range_Type is (Explicit_Range, Suffix_Range);
--
-- Ranges_Set -- Set of ranges with or without one suffix range
--
type Ranges_Set (Kind : Range_Type := Explicit_Range) is record
Set : Content_Ranges.Set; -- Specified ranges
case Kind is
when Explicit_Range =>
null;
when Suffix_Range =>
Tail : Stream_Element_Offset;
end case;
end record;
------------------------------------------------------------------------
Content_Not_Ready : exception;
--
-- Content_Source -- User-provided content
--
type Content_Source is
abstract new Ada.Finalization.Limited_Controlled with null record;
--
-- Get -- Get next piece of data
--
-- Source - The content source
--
-- The length of returned piece should not exceed the capacity of the
-- output buffer including prefix and suffix used for chunked transfer.
--
-- Returns :
--
-- The chunk of data
--
-- Exceptions :
--
-- Content_Not_Ready - No content ready yet
--
function Get (Source : access Content_Source)
return String is abstract;
------------------------------------------------------------------------
-- Content_Destination -- User-provided content
--
type Content_Destination is
abstract new Ada.Finalization.Limited_Controlled with null record;
--
-- Commit -- Finish receipt
--
-- Destination - The content
--
-- This procedure is called to finish successful receipt of the content.
-- The default implementation does nothing.
--
procedure Commit (Destination : in out Content_Destination);
--
-- Put -- Store next piece of data
--
-- Destination - The content
-- Data - Chunk of data to store
--
procedure Put
( Destination : in out Content_Destination;
Data : String
) is abstract;
--
-- CGI_Keys -- Key to value maps. Memory allocation of values in the
-- table is managed by the connection object. They shall not
-- be freed or changed.
--
type String_Ptr is access all String;
package CGI_Keys is new Tables (String_Ptr);
------------------------------------------------------------------------
-- HTTP_Client -- An object implementing HTTP 1.1 connection from a
-- client
--
-- Listener - The connection object
-- Request_Length - The maximum length of one request line
-- Input_Size - The input buffer size
-- Output_Size - The output buffer size
--
-- The output buffer size should be large enough to accommodate all
-- headers of a response and its status line and the body when that is
-- sent as a single string. The response body sent from a stream or a
-- content source using chunked transfer are not bound by t he output
-- buffer size.
--
type HTTP_Client
( Listener : access Connections_Server'Class;
Request_Length : Positive;
Input_Size : Buffer_Length;
Output_Size : Buffer_Length
) is new State_Machine with private;
--
-- Status_Line_Type -- Request status line type
--
-- None - Nothing specified
-- File - File path specified
-- URI - URI specified
--
type Status_Line_Type is (None, File, URI);
--
-- Status_Line -- Status line
--
type Status_Line
( Kind : Status_Line_Type;
Path_Length : Natural;
Host_Length : Natural;
Query_Length : Natural
) is
record
Query : String (1..Query_Length);
case Kind is
when None =>
null;
when File =>
File : String (1..Path_Length);
when URI =>
Scheme : Scheme_Type;
Host : String (1..Host_Length);
Port : Port_Type;
Path : String (1..Path_Length);
end case;
end record;
--
-- Finalize -- Destruction
--
-- Client - The client connection object
--
-- This procedure shall be called from the new implementation if
-- overridden by the derived type.
--
procedure Finalize (Client : in out HTTP_Client);
--
-- Get_Allowed -- The list options the server supports
--
-- Client - The client connection object
--
-- Returns :
--
-- The set of supported requests as reperted to OPTIONS
--
function Get_Allowed (Client : HTTP_Client) return HTTP_Allowed;
--
-- Get_Name -- The HTTP server name
--
-- Client - The client connection object
--
-- This function can be overridden to provide a custom name of the HTTP
-- server.
--
-- Returns :
--
-- The server name as told to the clients
--
function Get_Name (Client : HTTP_Client) return String;
--
-- Initialize -- Construction
--
-- Client - The client connection object
--
-- This procedure shall be called from the new implementation if
-- overridden by the derived type.
--
procedure Initialize (Client : in out HTTP_Client);
--
-- Received -- Overrides GNAT.Sockets.Connection_State_Machine...
--
procedure Received
( Client : in out HTTP_Client;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
);
--
-- Set_Allowed -- Change the list options the server supports
--
-- Client - The client connection object
-- Allowed - The set of supported requests (as reperted to OPTIONS)
--
procedure Set_Allowed
( Client : in out HTTP_Client;
Allowed : HTTP_Allowed
);
--
-- Trace -- Tracing
--
-- Client - The client connection object
-- Message - To write into the trace
--
procedure Trace
( Client : in out HTTP_Client;
Message : String
);
------------------------------------------------------------------------
--
-- Do_<method> -- Callback on client requests, such as GET and POST
--
-- Client - The client connection object
--
procedure Do_Connect (Client : in out HTTP_Client);
procedure Do_Delete (Client : in out HTTP_Client);
procedure Do_Get (Client : in out HTTP_Client);
procedure Do_Head (Client : in out HTTP_Client);
procedure Do_Options (Client : in out HTTP_Client);
procedure Do_Patch (Client : in out HTTP_Client);
procedure Do_Post (Client : in out HTTP_Client);
procedure Do_Put (Client : in out HTTP_Client);
procedure Do_Trace (Client : in out HTTP_Client);
procedure Do_WebSocket (Client : in out HTTP_Client);
------------------------------------------------------------------------
-- Request header information
--
-- Get_Closing -- The last connection request header
--
-- Client - The client connection object
--
-- When True is the result the connection will be closed as soon as the
-- last data are sent to the client.
--
-- Returns :
--
-- True if connection header has "close"
--
function Get_Closing (Client : HTTP_Client) return Boolean;
--
-- Get_Date -- The last date request header
--
-- Client - The client connection object
--
-- Returns :
--
-- The time stamp
--
-- Exceptions :
--
-- Time_Error - No date specified
--
function Get_Date (Client : HTTP_Client) return Time;
--
-- Get_Header -- The last request header specified as a text
--
-- Client - The client connection object
-- Header - Request header
--
-- Returns :
--
-- The header value of the current request or empty string
--
function Get_Header
( Client : HTTP_Client;
Header : Text_Header
) return String;
--
-- Get_If_Modified_Since -- The last date request header
--
-- Client - The client connection object
--
-- Returns :
--
-- The time stamp
--
function Get_If_Modified_Since (Client : HTTP_Client) return Time;
--
-- Get_If_Unmodified_Since -- The last date request header
--
-- Client - The client connection object
--
-- Returns :
--
-- The time stamp
--
function Get_If_Unmodified_Since (Client : HTTP_Client) return Time;
--
-- Get_Last_Modified -- The last date request header
--
-- Client - The client connection object
--
-- Returns :
--
-- The time stamp
--
function Get_Last_Modified (Client : HTTP_Client) return Time;
--
-- Get_Method -- The last request method
--
-- Client - The client connection object
--
-- Returns :
--
-- The method of the current request
--
function Get_Method (Client : HTTP_Client) return HTTP_Method;
--
-- Get_Ranges -- The ranges specified by the last request header
--
-- Client - The client connection object
--
-- Returns :
--
-- The ranges specified (empty if none)
--
function Get_Ranges (Client : HTTP_Client) return Ranges_Set;
--
-- Get_Status_Line -- The last request status line
--
-- Client - The client connection object
--
-- Returns :
--
-- The status line of the current request
--
function Get_Status_Line (Client : HTTP_Client) return Status_Line;
--
-- Get_Version -- The last request method
--
-- Client - The client connection object
--
-- Returns :
--
-- The version of the current request
--
function Get_Version (Client : HTTP_Client) return HTTP_Version;
------------------------------------------------------------------------
-- Sending response header fields:
--
-- Client - The client connection object
-- ... - Header parameters
--
-- The following procedures send response header field. The procedures
-- do not block. If the output buffer cannot accept the header then the
-- exception Data_Error is propagated. Note that the output buffer size
-- is controlled by the discriminant Output_Size.
--
-- Exceptions :
--
-- Data_Error - No room for output
--
-- Reply_{HTML|Text} -- Send short reply, usually error response
--
-- Client - The client connection object
-- Core - The status code, e.g. 404
-- Reason - The reason phrase, e.g. Not found
-- Message - The error response (plain text or HTML)
-- Get - Send body if true (no body is sent for POST requests)
--
procedure Reply_HTML
( Client : in out HTTP_Client;
Code : Positive;
Reason : String;
Message : String;
Get : Boolean := True
);
procedure Reply_Text
( Client : in out HTTP_Client;
Code : Positive;
Reason : String;
Message : String;
Get : Boolean := True
);
--
-- Send_Accept_Ranges -- Accept ranges infurmation
--
-- Client - The client connection object
-- Accept_Ranges - True if byte ranges are accepted, otherwise none
--
procedure Send_Accept_Ranges
( Client : in out HTTP_Client;
Accept_Ranges : Boolean
);
--
-- Send_Age -- Age field
--
-- Client - The client connection object
-- Age - The age to send
--
procedure Send_Age (Client : in out HTTP_Client; Age : Duration);
--
-- Send_Allow -- Allow field
--
-- Client - The client connection object
-- Allowed - The list of allowed options
--
procedure Send_Allow
( Client : in out HTTP_Client;
Allowed : HTTP_Allowed
);
--
-- Send_Connection -- Connection field
--
-- Client - The client connection object
-- Persistent - True if "keep-alive"
--
-- Note that Persistent True is ignored if the client already requested
-- connection closing. In that case "close" is responded anyway.
--
procedure Send_Connection
( Client : in out HTTP_Client;
Persistent : Boolean := True
);
--
-- Send_Content_Range -- Content-range field
--
-- Client - The client connection object
-- Content_Range - The range of the content
--
procedure Send_Content_Range
( Client : in out HTTP_Client;
Content_Range : String := "none"
);
--
-- Send_Content_Range -- Content-range field
--
-- Client - The client connection object
-- From - The range's lower bound
-- To - The range's upper bound
-- Length - The total content length
--
procedure Send_Content_Range
( Client : in out HTTP_Client;
From : Stream_Element_Count;
To : Stream_Element_Count;
Length : Stream_Element_Count
);
--
-- Send_Content_Type -- Content-type field
--
-- Client - The client connection object
-- Media - The media type
-- Charset - The character set
--
procedure Send_Content_Type
( Client : in out HTTP_Client;
Media : String := "text/plain";
Charset : String := "UTF-8"
);
--
-- Send_Date -- Date field
--
-- Client - The client connection object
-- Date - The time to send
--
procedure Send_Date
( Client : in out HTTP_Client;
Date : Time := Clock
);
--
-- Send_If_Modified_Since -- Date field
--
-- Client - The client connection object
-- Date - The time to send
--
procedure Send_If_Modified_Since
( Client : in out HTTP_Client;
Date : Time
);
--
-- Send_If_Unmodified_Since -- Date field
--
-- Client - The client connection object
-- Date - The time to send
--
procedure Send_If_Unmodified_Since
( Client : in out HTTP_Client;
Date : Time
);
--
-- Send_Last_Modified -- Date field
--
-- Client - The client connection object
-- Date - The time to send
--
procedure Send_Last_Modified
( Client : in out HTTP_Client;
Date : Time
);
--
-- Send_Length -- Content-length field
--
-- Client - The client connection object
-- Length - The length of content
--
procedure Send_Length
( Client : in out HTTP_Client;
Length : Natural
);
procedure Send_Length
( Client : in out HTTP_Client;
Length : Stream_Element_Count
);
--
-- Send_Server -- Server field
--
-- Client - The client connection object
--