|
| 1 | +------------------------------------------------------------------------------ |
| 2 | +-- Ada Web Server -- |
| 3 | +-- -- |
| 4 | +-- Copyright (C) 2020, 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 Ada.Streams; |
| 20 | +with Ada.Text_IO; |
| 21 | + |
| 22 | +with AWS.Client; |
| 23 | +with AWS.Messages; |
| 24 | +with AWS.MIME; |
| 25 | +with AWS.Net.Log; |
| 26 | +with AWS.Parameters; |
| 27 | +with AWS.Response; |
| 28 | +with AWS.Server.Status; |
| 29 | +with AWS.Status; |
| 30 | +with AWS.Translator; |
| 31 | +with AWS.Utils; |
| 32 | + |
| 33 | +procedure Big_Post is |
| 34 | + |
| 35 | + use Ada; |
| 36 | + use Ada.Streams; |
| 37 | + use AWS; |
| 38 | + |
| 39 | + type String_Access is access String; |
| 40 | + |
| 41 | + -------- |
| 42 | + -- CB -- |
| 43 | + -------- |
| 44 | + |
| 45 | + function CB (Request : Status.Data) return Response.Data is |
| 46 | + begin |
| 47 | + Text_IO.Put_Line |
| 48 | + ("Length payload: " & Status.Content_Length (Request)'Img); |
| 49 | + return Response.Build (MIME.Text_HTML, "ok"); |
| 50 | + end CB; |
| 51 | + |
| 52 | + WS : Server.HTTP; |
| 53 | + M_Body : String_Access; |
| 54 | + R : Response.Data; |
| 55 | + |
| 56 | +begin |
| 57 | + Server.Start (WS, "Big Post", CB'Unrestricted_Access, Port => 0); |
| 58 | + |
| 59 | + Text_IO.Put_Line ("started"); |
| 60 | + Text_IO.Flush; |
| 61 | + |
| 62 | + M_Body := new String'(1 .. 16_000_000 => 'a'); |
| 63 | + |
| 64 | + R := Client.Post |
| 65 | + (Server.Status.Local_URL (WS) & "/big_post", |
| 66 | + M_Body.all, |
| 67 | + Content_Type => MIME.Text_HTML); |
| 68 | + |
| 69 | + Text_IO.Put_Line (Response.Message_Body (R)); |
| 70 | + |
| 71 | + Server.Shutdown (WS); |
| 72 | + Text_IO.Put_Line ("shutdown"); |
| 73 | +end Big_Post; |
0 commit comments