Request.h
Aller à la documentation de ce fichier.
1 /*
2  * Copyright © (2011-2013) Institut national de l'information
3  * géographique et forestière
4  *
5  * Géoportail SAV <contact.geoservices@ign.fr>
6  *
7  * This software is a computer program whose purpose is to publish geographic
8  * data using OGC WMS and WMTS protocol.
9  *
10  * This software is governed by the CeCILL-C license under French law and
11  * abiding by the rules of distribution of free software. You can use,
12  * modify and/ or redistribute the software under the terms of the CeCILL-C
13  * license as circulated by CEA, CNRS and INRIA at the following URL
14  * "http://www.cecill.info".
15  *
16  * As a counterpart to the access to the source code and rights to copy,
17  * modify and redistribute granted by the license, users are provided only
18  * with a limited warranty and the software's author, the holder of the
19  * economic rights, and the successive licensors have only limited
20  * liability.
21  *
22  * In this respect, the user's attention is drawn to the risks associated
23  * with loading, using, modifying and/or developing or reproducing the
24  * software by the user in light of its specific status of free software,
25  * that may mean that it is complicated to manipulate, and that also
26  * therefore means that it is reserved for developers and experienced
27  * professionals having in-depth computer knowledge. Users are therefore
28  * encouraged to load and test the software's suitability as regards their
29  * requirements in conditions enabling the security of their systems and/or
30  * data to be ensured and, more generally, to use and operate it in the
31  * same conditions as regards security.
32  *
33  * The fact that you are presently reading this means that you have had
34  *
35  * knowledge of the CeCILL-C license and that you accept its terms.
36  */
37 
38 class Request;
39 
40 #ifndef REQUEST_H_
41 #define REQUEST_H_
42 
43 #include <map>
44 #include <vector>
45 #include <rok4/utils/BoundingBox.h>
46 #include <rok4/datasource/DataSource.h>
47 #include <rok4/utils/CRS.h>
48 #include "Layer.h"
49 #include "ServicesConf.h"
50 #include "fcgiapp.h"
51 
62 namespace RequestType {
67  enum eRequestType {
68  REQUEST_UNKNOWN,
69  REQUEST_MISSING,
70  GETSERVICES,
71  GETCAPABILITIES,
72  GETLAYER,
73  GETLAYERMETADATA,
74  GETLAYERGDAL,
75  GETMAP,
76  GETTILE,
77  GETMAPTILE,
78  GETFEATUREINFO,
79  GETVERSION,
80  ADDLAYER,
81  UPDATELAYER,
82  DELETELAYER,
83  BUILDCAPABILITIES,
84  TURNON,
85  TURNOFF,
86  GETHEALTHSTATUS,
87  GETINFOSTATUS,
88  GETTHREADSTATUS,
89  GETDEPENDSTATUS
90  };
91 
92 
101  std::string toString ( eRequestType rt );
102 
103 }
104 
105 
106 namespace ServiceType {
112  SERVICE_UNKNOWN,
113  SERVICE_MISSING,
114  WMTS,
115  WMS,
116  TMS,
117  OGCTILES,
118  GLOBAL,
119  ADMIN,
120  HEALTHCHECK
121  };
122 
131  std::string toString ( eServiceType st );
132 }
133 
134 namespace TemplateOGC {
139  // raster tile
140  GETTILERASTERSTYLED,
141  GETTILERASTER,
142  GETTILERASTERSTYLEDBYCOLLECTION,
143  GETTILERASTERBYCOLLECTION,
144  // vector tile
145  GETTILEVECTOR,
146  GETTILEVECTORBYCOLLECTION,
147  // capabilities
148  GETCAPABILITIESBYCOLLECTION,
149  GETCAPABILITIESRASTERBYCOLLECTION,
150  GETCAPABILITIESVECTORBYCOLLECTION,
151  // tilematrixset
152  GETTILEMATRIXSET,
153  GETTILEMATRIXSETBYID
154  };
158  std::string toString ( eTemplateOGC r );
159 }
160 
176 class Request {
177  friend class CppUnitRequest;
178 
179 private:
188  void url_decode ( char *src );
189 
196  void determineServiceAndRequest();
197 
198 public:
199 
208  static void toLowerCase ( char* str ) {
209  if ( str ) for ( int i = 0; str[i]; i++ ) str[i] = tolower ( str[i] );
210  }
211 
222  bool hasParam ( std::string paramName );
223 
234  std::string getParam ( std::string paramName );
235 
240  std::string method;
245  std::string path;
250  std::vector<std::string> pathParts;
266 
271  std::map<std::string, std::string> queryParams;
272 
277  std::map<std::string, std::string> bodyParams;
278 
283  std::string body;
284 
289  void print() {
290  BOOST_LOG_TRIVIAL(info) << "path = " << path;
291  BOOST_LOG_TRIVIAL(info) << "method = " << method;
292  BOOST_LOG_TRIVIAL(info) << "service = " << ServiceType::toString(service);
293  BOOST_LOG_TRIVIAL(info) << "request = " << RequestType::toString(request);
294  }
295 
304  Request ( FCGX_Request& fcgxRequest);
305 
312  virtual ~Request();
313 };
314 
315 #endif /* REQUEST_H_ */
Request::toLowerCase
static void toLowerCase(char *str)
Transforme la chaîne de caractères en minuscule.
Definition: Request.h:208
Request::getParam
std::string getParam(std::string paramName)
Récupération de la valeur d'un paramètre dans la requête.
Definition: Request.cpp:1025
Request::tmpl
TemplateOGC::eTemplateOGC tmpl
Type de templates OGC.
Definition: Request.h:265
RequestType::eRequestType
eRequestType
Énumération des types de requête.
Definition: Request.h:67
TemplateOGC::eTemplateOGC
eTemplateOGC
Énumération des templates d'URL OGC.
Definition: Request.h:138
Request::method
std::string method
Méthode de la requête (GET, POST, PUT, DELETE)
Definition: Request.h:240
Request::pathParts
std::vector< std::string > pathParts
Chemin découpé
Definition: Request.h:250
Layer.h
Définition de la classe Layer modélisant les couches de données.
Request::service
ServiceType::eServiceType service
Type de service (WMS,WMTS,TMS,OGC)
Definition: Request.h:260
Request::bodyParams
std::map< std::string, std::string > bodyParams
Liste des paramètres extraits du corps de la requête.
Definition: Request.h:277
Request::~Request
virtual ~Request()
Destructeur par défaut.
Definition: Request.cpp:1012
Request::print
void print()
Affichage (debug)
Definition: Request.h:289
Request::request
RequestType::eRequestType request
Nom au sens OGC de la requête effectuée.
Definition: Request.h:255
ServiceType::eServiceType
eServiceType
Énumération des services.
Definition: Request.h:111
Request::hasParam
bool hasParam(std::string paramName)
Test de la présence d'un paramètre dans la requête.
Definition: Request.cpp:1014
Request
Gestion des requêtes HTTP.
Definition: Request.h:176
Request::queryParams
std::map< std::string, std::string > queryParams
Liste des paramètres de la requête.
Definition: Request.h:271
Request::body
std::string body
Corps de la requête.
Definition: Request.h:283
Request::path
std::string path
Chemin du serveur web pour accèder au service.
Definition: Request.h:245
Request::Request
Request(FCGX_Request &fcgxRequest)
Constructeur d'une requête.
Definition: Request.cpp:952