Skip to content

Commit e00b68a

Browse files
committed
Merge branch 'po/client-http2'
* po/client-http2: (51 commits) Simplify code by using To_Lower as in pure HTTP/2 unit. Ensure we handle possible corruped data/frames. Add some pre-conditions. Minor code clean-up. Properly initialize the connection object based on settings. Clean-up multiple definitions of CRLF. Minor code reformatting and clean-up. Code refactoring, better sharing. Rework the handling of headers for HTTP/2 responses. Send_Request_2: Rewrite to properly handle large request & response. Read_Body is only to be used with HTTP/1.x. Fix POST support, nothing to do if the body is empty. New routine HTTP_Version to get the connection's protocol version. Add new routine to directly set the headers list. Fix implementation of POST without attachment. Refactor code for sharing. Add initial support for POST with attachments for HTTP/2. Properly update connection flow control window. Fix wrong initialization of Max_Frame_Size (cut&paste) error. Use a unique port for 0345_http2_soap_hello. ...
2 parents 70133fe + 36373d7 commit e00b68a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2908
-816
lines changed

regtests/0341_hpack/main.adb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,18 @@ procedure Main is
7777
end loop;
7878
end Print;
7979

80-
M : AWS.Headers.List := Decode (Tab_Dec'Access, Settings'Access);
80+
M : constant AWS.Headers.List :=
81+
Decode (Tab_Dec'Access, Settings'Access);
8182

8283
use type AWS.Headers.List;
8384
use type AWS.HTTP2.HPACK.Table.Object;
8485

8586
begin
8687
if M /= H then
87-
Ada.Text_IO.Put_Line ("Headers differ");
88+
Ada.Text_IO.Put_Line ("============= Headers differ");
8889
Print (H);
8990
Print (M);
91+
New_Line;
9092
end if;
9193

9294
if Tab_Enc /= Tab_Dec then
@@ -100,6 +102,8 @@ procedure Main is
100102
Size : Positive;
101103

102104
begin
105+
H.Case_Sensitive (False);
106+
103107
H.Add (":method", "GET");
104108
H.Add (":path", "/readme.txt");
105109
H.Add (":scheme", "https");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!xmlada DEAD
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello AWS and welcome in H2! 12
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from test_support import *
2+
3+
exec_cmd('wsdl2aws', ['-q', '-f', '-doc', 'wsdl_h2hello.wsdl'])
4+
build_and_run('wsdl_h2hello')
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2021, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
-- SOAP/WSDL test
20+
21+
with Ada.Strings.Unbounded;
22+
with Ada.Text_IO;
23+
24+
with AWS.Config.Set;
25+
with AWS.MIME;
26+
with AWS.Net;
27+
with AWS.Response;
28+
with AWS.Server.Status;
29+
with AWS.Status;
30+
31+
with SOAP.Types;
32+
with SOAP.Utils;
33+
34+
with R_Hello_Demo.Client;
35+
with R_Hello_Demo.Server;
36+
with R_Hello_Demo.Types;
37+
38+
procedure WSDL_H2Hello is
39+
40+
use Ada.Strings.Unbounded;
41+
use AWS;
42+
use R_Hello_Demo.Types;
43+
44+
H_Server : Server.HTTP;
45+
CNF : Config.Object;
46+
47+
procedure WSDL_Demo_Client is
48+
use Ada;
49+
R : Sayhello_Result;
50+
begin
51+
R := R_Hello_Demo.Client.sayHello (Firstname => "AWS");
52+
Text_IO.Put_Line
53+
(To_String (R.Message) & SOAP.Types.Short'Image (R.Token));
54+
end WSDL_Demo_Client;
55+
56+
function sayHello (Firstname : String) return Sayhello_Result;
57+
58+
-------------
59+
-- SOAP_CB --
60+
-------------
61+
62+
function SOAP_CB is new R_Hello_Demo.Server.sayHello_CB (sayHello);
63+
64+
function SOAP_Wrapper is new SOAP.Utils.SOAP_Wrapper (SOAP_CB);
65+
66+
--------
67+
-- CB --
68+
--------
69+
70+
function CB (Request : Status.Data) return Response.Data is
71+
SOAPAction : constant String := Status.SOAPAction (Request);
72+
begin
73+
if SOAPAction = "sayHello" then
74+
return SOAP_Wrapper (Request);
75+
else
76+
return Response.Build (MIME.Text_HTML, "<p>Not a SOAP request");
77+
end if;
78+
end CB;
79+
80+
--------------
81+
-- sayHello --
82+
--------------
83+
84+
function sayHello (Firstname : String) return Sayhello_Result is
85+
begin
86+
return
87+
(To_Unbounded_String
88+
("Hello " & Firstname & " and welcome in H2!"), 12);
89+
end sayHello;
90+
91+
begin
92+
Config.Set.Server_Name (CNF, "WSDL Hello demo");
93+
Config.Set.Server_Host (CNF, "localhost");
94+
Config.Set.Server_Port (CNF, R_Hello_Demo.Server.Port);
95+
Config.Set.HTTP2_Activated (CNF, True);
96+
97+
Server.Start (H_Server, CB'Unrestricted_Access, CNF);
98+
99+
if Net.IPv6_Available then
100+
-- Need to start second server on same port but on the different
101+
-- Protocol_Family because we do not know which family would client try
102+
-- to connect.
103+
104+
if AWS.Server.Status.Is_IPv6 (H_Server) then
105+
Server.Add_Listening
106+
(H_Server, "localhost", R_Hello_Demo.Server.Port, Net.FAMILY_INET);
107+
else
108+
Server.Add_Listening
109+
(H_Server, "localhost", R_Hello_Demo.Server.Port, Net.FAMILY_INET6);
110+
end if;
111+
end if;
112+
113+
WSDL_Demo_Client;
114+
115+
Server.Shutdown (H_Server);
116+
end WSDL_H2Hello;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2021, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with "aws";
20+
21+
project WSDL_H2Hello is
22+
for Source_Dirs use (".");
23+
for Main use ("wsdl_h2hello.adb");
24+
end WSDL_H2Hello;
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions name="HelloService"
3+
targetNamespace="http://www.s.com/wsdl/hs.wsdl"
4+
xmlns="http://schemas.xmlsoap.org/wsdl/"
5+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6+
xmlns:tns="http://www.s.com/wsdl/hs.wsdl"
7+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
8+
xmlns:ns1="urn:examples:helloservice">
9+
10+
<types>
11+
<schema>
12+
<complexType name="ArrayOffloat">
13+
<xsd:annotation>
14+
<xsd:documentation>
15+
A set of float
16+
</xsd:documentation>
17+
</xsd:annotation>
18+
<complexContent>
19+
<restriction base="soap-enc:Array">
20+
<attribute ref="soap-enc:arrayType" arrayType="xsd:float[]"/>
21+
</restriction>
22+
</complexContent>
23+
</complexType>
24+
25+
<xsd:complexType name="HelloResponse">
26+
<xsd:annotation>
27+
<xsd:documentation>
28+
A message/token pair
29+
</xsd:documentation>
30+
</xsd:annotation>
31+
<xsd:sequence>
32+
<xsd:element name="message" type="xsd:string">
33+
<xsd:annotation>
34+
<xsd:documentation>
35+
The reponse string.
36+
</xsd:documentation>
37+
</xsd:annotation>
38+
</xsd:element>
39+
<xsd:element name="token" type="xsd:short">
40+
<xsd:annotation>
41+
<xsd:documentation>
42+
Value representing the length of the response.
43+
</xsd:documentation>
44+
</xsd:annotation>
45+
</xsd:element>
46+
</xsd:sequence>
47+
</xsd:complexType>
48+
</schema>
49+
</types>
50+
51+
<message name="SayHelloRequest">
52+
<part name="firstName" type="xsd:string"/>
53+
</message>
54+
<message name="SayHelloResponse">
55+
<part name="greeting" type="HelloResponse"/>
56+
</message>
57+
58+
<message name="CallRequest">
59+
<part name="firstName" type="ArrayOffloat"/>
60+
</message>
61+
<message name="CallResponse">
62+
<part name="greeting" type="xsd:int"/>
63+
</message>
64+
65+
<portType name="Hello_PortType">
66+
<documentation>
67+
This web service provides a simple Hello World.
68+
</documentation>
69+
<operation name="sayHello">
70+
<documentation>
71+
Called with a firstName, and returns a greeting message.
72+
This is very simple SOAP callback. The input message is a simple string,
73+
the response is a complexType with the response and a uniq token value.
74+
</documentation>
75+
<input message="tns:SayHelloRequest"/>
76+
<output message="tns:SayHelloResponse"/>
77+
</operation>
78+
<operation name="call">
79+
<documentation>
80+
just for the documentation validation.
81+
</documentation>
82+
<input message="tns:CallRequest"/>
83+
<output message="tns:CallResponse"/>
84+
</operation>
85+
</portType>
86+
87+
<binding name="Hello_Binding" type="tns:Hello_PortType">
88+
<soap:binding style="rpc"
89+
transport="http://schemas.xmlsoap.org/soap/http"/>
90+
<operation name="sayHello">
91+
<soap:operation soapAction="sayHello"/>
92+
<input>
93+
<soap:body
94+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
95+
namespace="urn:examples:helloservice"
96+
use="encoded"/>
97+
</input>
98+
<output>
99+
<soap:body
100+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
101+
namespace="urn:examples:helloservice"
102+
use="encoded"/>
103+
</output>
104+
</operation>
105+
<operation name="call">
106+
<soap:operation soapAction="sayHello"/>
107+
<input>
108+
<soap:body
109+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
110+
namespace="urn:examples:helloservice"
111+
use="encoded"/>
112+
</input>
113+
<output>
114+
<soap:body
115+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
116+
namespace="urn:examples:helloservice"
117+
use="encoded"/>
118+
</output>
119+
</operation>
120+
</binding>
121+
122+
<service name="R_Hello_Demo">
123+
<documentation>
124+
WSDL File for Hello AWS Demo.
125+
</documentation>
126+
<port binding="tns:Hello_Binding" name="Hello_Port">
127+
<soap:address
128+
location="http://localhost:9837/hello"/>
129+
</port>
130+
</service>
131+
</definitions>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file2

0 commit comments

Comments
 (0)