Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/webdriver-server/uri_info.h
2867 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
// Defines the server to respond to WebDriver JSON wire protocol commands.
18
// Subclasses are expected to provide their own initialization mechanism.
19
20
#ifndef WEBDRIVER_SERVER_URI_INFO_H_
21
#define WEBDRIVER_SERVER_URI_INFO_H_
22
23
#include <map>
24
#include <string>
25
#include <vector>
26
27
namespace webdriver {
28
29
class UriInfo {
30
public:
31
UriInfo(const std::string& uri,
32
const std::string& verb,
33
const std::string& command_name);
34
35
static void ParseUri(const std::string& uri,
36
std::vector<std::string>* fragments,
37
std::vector<size_t>* parameter_indexes);
38
39
bool IsUriMatch(const std::vector<std::string>& uri_fragments,
40
std::vector<std::string>* uri_param_names,
41
std::vector<std::string>* uri_param_values);
42
bool HasHttpVerb(const std::string& http_verb, std::string* command_name);
43
std::string GetSupportedVerbs(void);
44
void AddHttpVerb(const std::string& http_verb,
45
const std::string& command_name);
46
47
private:
48
typedef std::map<std::string, std::string> HttpVerbMap;
49
50
bool IsValidParameterValue(const std::string& param_name,
51
const std::string& param_value);
52
53
std::vector<std::string> fragments_;
54
std::vector<size_t> parameter_indexes_;
55
HttpVerbMap verb_map_;
56
57
DISALLOW_COPY_AND_ASSIGN(UriInfo);
58
};
59
60
} // namespace WebDriver
61
62
#endif // WEBDRIVER_SERVER_URI_INFO_H_
63
64