comp.lang.ada
 help / color / mirror / Atom feed
* HTTP with Simple Components: Status.Kind always File
@ 2017-07-17 18:30 Felix Krause
  2017-07-17 20:59 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 16+ messages in thread
From: Felix Krause @ 2017-07-17 18:30 UTC (permalink / raw)


I am trying to implement an HTTP server with Simple Components. My 
problem is that whenever I send a request to the server, in Do_Get, 
Status.Kind is File instead of URI. Relevant parts of my code:

    package Yaml.Servers is
       package HTTP renames GNAT.Sockets.Connection_State_Machine.HTTP_Server;
       package Server renames GNAT.Sockets.Server;

       type Yaml_Factory (Request_Length  : Positive;
                          Input_Size      : Server.Buffer_Length;
                          Output_Size     : Server.Buffer_Length;
                          Max_Connections : Positive) is
         new Server.Connections_Factory with null record;

       type Yaml_Client is new HTTP.HTTP_Client with null record;

       overriding function Create (Factory  : access Yaml_Factory;
                                   Listener : access 
Server.Connections_Server'Class;
                                   From     : GNAT.Sockets.Sock_Addr_Type)
                                   return Server.Connection_Ptr is
          (new Yaml_Client (Listener       => Listener.all'Unchecked_Access,
                            Request_Length => Factory.Request_Length,
                            Input_Size     => Factory.Input_Size,
                            Output_Size    => Factory.Output_Size));

       overriding procedure Do_Get (Client : in out Yaml_Client);
    end Yaml.Servers;

    package body Yaml.Servers is
       procedure Do_Get (Client : in out Yaml_Client) is
          Status : HTTP.Status_Line renames Get_Status_Line (Client);
       begin
          case Status.Kind is
             when HTTP.None =>
                ...
             when HTTP.File =>
                ...
             when HTTP.URI =>
                ...
          end case;
       end Do_Get;
    end Yaml.Servers;

    procedure Yaml.Server is
       Factory : aliased Servers.Yaml_Factory (200, 80, 8192, 100);
       Server  : Servers.Server.Connections_Server (Factory'Access, 8088);
       pragma Unreferenced (Server);
    begin
       Ada.Text_IO.Put_Line ("HTTP server started.");
       loop
          delay 60.0;
       end loop;
    end Yaml.Server;

Now I run this server behind an nginx, and it responds as expected. 
However, when I access it with an URI `http://ada.yaml.io/widget/`, 
inside Do_Get, Status.Kind is File. Why is this? With the File kind, I 
cannot possibly parse the query at this point, because I cannot 
differentiate between `%26` and `&` (entities have already been 
resolved).

I also tested this locally with `http://localhost:8888/widget/`, and 
that also yields a file.

How can I make the HTTP server to yield an URI instead of a File?

Cheers,
Felix

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-07-21  7:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-17 18:30 HTTP with Simple Components: Status.Kind always File Felix Krause
2017-07-17 20:59 ` Dmitry A. Kazakov
2017-07-19 16:09   ` Felix Krause
2017-07-19 16:33     ` Dmitry A. Kazakov
2017-07-19 19:31       ` Randy Brukardt
2017-07-19 21:13       ` Felix Krause
2017-07-20  8:57         ` Dmitry A. Kazakov
2017-07-20 13:35           ` Felix Krause
2017-07-20 13:57             ` Dmitry A. Kazakov
2017-07-20 14:19               ` Felix Krause
2017-07-20 20:29             ` Simon Wright
2017-07-20 20:57               ` Dmitry A. Kazakov
2017-07-20 21:12                 ` Felix Krause
2017-07-21  7:14                   ` Dmitry A. Kazakov
2017-07-21  7:06                 ` Simon Wright
2017-07-21  7:15                   ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox