├── .circleci
└── config.yml
├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── README.md
├── UNLICENSE
├── azure-pipelines.yml
├── example
├── Makefile
├── example.sln
├── example.vcxproj
├── example.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
└── main.cpp
├── include
└── HTTPRequest.hpp
├── sonar-project.properties
└── tests
├── CMakeLists.txt
├── Makefile
├── encoding.cpp
├── main.cpp
├── parsing.cpp
├── tests.sln
├── tests.vcxproj
└── tests.xcodeproj
├── project.pbxproj
└── project.xcworkspace
└── contents.xcworkspacedata
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | jobs:
4 | test:
5 | docker:
6 | - image: gcc:8.2
7 | steps:
8 | - checkout
9 | - run: git submodule update --init
10 | - run:
11 | name: Download SonarCloud
12 | command: |
13 | mkdir -p $HOME/.sonar
14 | wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip -P $HOME/.sonar
15 | unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
16 | - run:
17 | name: Build and run
18 | command: |
19 | export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
20 | build-wrapper-linux-x86-64 --out-dir bw-output make -C tests/
21 | tests/tests
22 | - run:
23 | name: Generate coverage
24 | command: |
25 | cd tests
26 | gcov encoding.cpp main.cpp parsing.cpp
27 | - sonarcloud/scan
28 |
29 | orbs:
30 | sonarcloud: sonarsource/sonarcloud@1.0.3
31 |
32 | workflows:
33 | main:
34 | jobs:
35 | - test:
36 | context: SonarCloud
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | example/example.xcodeproj/project.xcworkspace/xcshareddata
2 | example/example.xcodeproj/project.xcworkspace/xcuserdata
3 | example/example.xcodeproj/xcshareddata
4 | example/example.xcodeproj/xcuserdata
5 | example/.vs
6 | example/Win32
7 | example/x64/
8 | example/example.opensdf
9 | example/example.sdf
10 | example/example.VC.db
11 | example/example.VC.VC.opendb
12 | example/example
13 | example/example.exe
14 | *.o
15 | *.d
16 | *.user
17 | tests/tests.xcodeproj/project.xcworkspace/xcshareddata
18 | tests/tests.xcodeproj/project.xcworkspace/xcuserdata
19 | tests/tests.xcodeproj/xcshareddata
20 | tests/tests.xcodeproj/xcuserdata
21 | tests/.vs
22 | tests/Win32
23 | tests/x64/
24 | tests/tests.opensdf
25 | tests/tests.sdf
26 | tests/tests.VC.db
27 | tests/tests.VC.VC.opendb
28 | tests/tests
29 | tests/tests.exe
30 | *.gcov
31 | *.gcda
32 | *.gcno
33 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "external/Catch2"]
2 | path = external/Catch2
3 | url = https://github.com/catchorg/Catch2.git
4 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(HTTPRequest CXX)
3 |
4 | # Header only library will be interface. All properties get passed to targets that 'link' to it
5 | add_library(HTTPRequest INTERFACE)
6 | target_compile_features(HTTPRequest INTERFACE cxx_std_17)
7 |
8 | target_include_directories(HTTPRequest
9 | INTERFACE
10 | ${CMAKE_CURRENT_SOURCE_DIR}/include
11 | )
12 |
13 | # Optionally build unit tests
14 | option(BUILD_TESTING "Build Unit Tests" OFF)
15 | if (BUILD_TESTING)
16 | enable_testing()
17 | add_subdirectory(tests)
18 | endif()
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HTTPRequest
2 |
3 | HTTPRequest is a single-header C++ library for making HTTP requests. You can just include it in your project and use it. HTTPRequest was tested on macOS, Windows, Haiku, BSD, and GNU/Linux, but it should work on most of the Linux-based platforms. Supports IPv4 and IPv6. HTTPRequest requires C++17 or newer.
4 |
5 | ## Usage
6 |
7 | To use the library simply include `HTTPRequest.hpp` using `#include "HTTPRequest.hpp"`.
8 |
9 | ### Example of a GET request
10 | ```cpp
11 | try
12 | {
13 | // you can pass http::InternetProtocol::V6 to Request to make an IPv6 request
14 | http::Request request{"http://test.com/test"};
15 |
16 | // send a get request
17 | const auto response = request.send("GET");
18 | std::cout << std::string{response.body.begin(), response.body.end()} << '\n'; // print the result
19 | }
20 | catch (const std::exception& e)
21 | {
22 | std::cerr << "Request failed, error: " << e.what() << '\n';
23 | }
24 | ```
25 |
26 | ### Example of a POST request with form data
27 | ```cpp
28 | try
29 | {
30 | http::Request request{"http://test.com/test"};
31 | const string body = "foo=1&bar=baz";
32 | const auto response = request.send("POST", body, {
33 | {"Content-Type", "application/x-www-form-urlencoded"}
34 | });
35 | std::cout << std::string{response.body.begin(), response.body.end()} << '\n'; // print the result
36 | }
37 | catch (const std::exception& e)
38 | {
39 | std::cerr << "Request failed, error: " << e.what() << '\n';
40 | }
41 | ```
42 |
43 | ### Example of a POST request with a JSON body
44 | ```cpp
45 | try
46 | {
47 | http::Request request{"http://test.com/test"};
48 | const std::string body = "{\"foo\": 1, \"bar\": \"baz\"}";
49 | const auto response = request.send("POST", body, {
50 | {"Content-Type", "application/json"}
51 | });
52 | std::cout << std::string{response.body.begin(), response.body.end()} << '\n'; // print the result
53 | }
54 | catch (const std::exception& e)
55 | {
56 | std::cerr << "Request failed, error: " << e.what() << '\n';
57 | }
58 | ```
59 |
60 | ### Example of a GET request using Basic authorization
61 | ```cpp
62 | try
63 | {
64 | http::Request request{"http://user:password@test.com/test"};
65 | const auto response = request.send("GET");
66 | std::cout << std::string{response.body.begin(), response.body.end()} << '\n'; // print the result
67 | }
68 | catch (const std::exception& e)
69 | {
70 | std::cerr << "Request failed, error: " << e.what() << '\n';
71 | }
72 | ```
73 |
74 | To set a timeout for HTTP requests, pass `std::chrono::duration` as a last parameter to `send()`. A negative duration (default) passed to `send()` disables timeout.
75 |
76 | ## License
77 |
78 | HTTPRequest is released to the Public Domain.
79 |
--------------------------------------------------------------------------------
/UNLICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | - master
3 |
4 | jobs:
5 | - job: Tests_Linux
6 | displayName: Tests on Linux
7 | pool:
8 | vmImage: 'Ubuntu-latest'
9 | steps:
10 | - checkout: self
11 | submodules: true
12 | - script: |
13 | cd tests
14 | make -j2
15 | displayName: 'make'
16 | - script: |
17 | cd tests
18 | ./tests
19 | displayName: 'run'
20 |
21 | - job: Tests_Windows
22 | displayName: Tests on Windows
23 | pool:
24 | vmImage: 'vs2017-win2016'
25 | steps:
26 | - checkout: self
27 | submodules: true
28 | - task: MSBuild@1
29 | inputs:
30 | solution: tests/tests.vcxproj
31 | configuration: Release
32 | - script: |
33 | cd tests/Win32/Release
34 | tests.exe
35 | displayName: 'run'
36 |
37 | - job: Tests_macOS
38 | displayName: Tests on macOS
39 | pool:
40 | vmImage: 'macOS-10.15'
41 | steps:
42 | - checkout: self
43 | submodules: true
44 | - script: |
45 | cd tests
46 | make -j2
47 | displayName: 'make'
48 | - script: |
49 | cd tests
50 | ./tests
51 | displayName: 'run'
52 |
53 | - job: Example_Linux
54 | displayName: Example on Linux
55 | pool:
56 | vmImage: 'Ubuntu-latest'
57 | steps:
58 | - script: |
59 | cd example
60 | make -j2
61 | displayName: 'make'
62 |
63 | - job: Example_Windows
64 | displayName: Example on Windows
65 | pool:
66 | vmImage: 'vs2017-win2016'
67 | steps:
68 | - task: MSBuild@1
69 | inputs:
70 | solution: example/example.vcxproj
71 | configuration: Release
72 |
73 | - job: Example_macOS
74 | displayName: Example on macOS
75 | pool:
76 | vmImage: 'macOS-10.15'
77 | steps:
78 | - script: |
79 | cd example
80 | make -j2
81 | displayName: 'make'
82 |
--------------------------------------------------------------------------------
/example/Makefile:
--------------------------------------------------------------------------------
1 | DEBUG=0
2 | ifeq ($(OS),Windows_NT)
3 | platform=windows
4 | else ifeq ($(shell uname -s),Linux)
5 | platform=linux
6 | endif
7 | ifeq ($(shell uname -s),Darwin)
8 | platform=macos
9 | else ifeq ($(shell uname -s),Haiku)
10 | platform=haiku
11 | endif
12 |
13 | CXXFLAGS=-std=c++11 -Wall -Wshadow -O2 -I../include
14 | LDFLAGS=-O2
15 | ifeq ($(platform),windows)
16 | LDFLAGS+=-lws2_32
17 | else ifeq ($(platform),haiku)
18 | LDFLAGS+=-lnetwork
19 | endif
20 | SOURCES=main.cpp
21 | BASE_NAMES=$(basename $(SOURCES))
22 | OBJECTS=$(BASE_NAMES:=.o)
23 | DEPENDENCIES=$(OBJECTS:.o=.d)
24 | EXECUTABLE=example
25 |
26 | all: $(EXECUTABLE)
27 | ifeq ($(DEBUG),1)
28 | all: CXXFLAGS+=-DDEBUG -g
29 | endif
30 |
31 | $(EXECUTABLE): $(OBJECTS)
32 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
33 |
34 | -include $(DEPENDENCIES)
35 |
36 | %.o: %.cpp
37 | $(CXX) -c $(CXXFLAGS) -MMD -MP $< -o $@
38 |
39 | .PHONY: clean
40 | clean:
41 | $(RM) $(EXECUTABLE) $(OBJECTS) $(DEPENDENCIES) $(EXECUTABLE).exe
--------------------------------------------------------------------------------
/example/example.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{614C7EC0-3262-40DF-B884-224B959A01F9}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Debug|x64 = Debug|x64
12 | Release|Win32 = Release|Win32
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Debug|Win32.ActiveCfg = Debug|Win32
17 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Debug|Win32.Build.0 = Debug|Win32
18 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Debug|x64.ActiveCfg = Debug|x64
19 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Debug|x64.Build.0 = Debug|x64
20 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Release|Win32.ActiveCfg = Release|Win32
21 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Release|Win32.Build.0 = Release|Win32
22 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Release|x64.ActiveCfg = Release|x64
23 | {614C7EC0-3262-40DF-B884-224B959A01F9}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/example/example.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | {614C7EC0-3262-40DF-B884-224B959A01F9}
29 | Win32Proj
30 | rtmp_relay
31 | 10.0
32 |
33 |
34 |
35 | Application
36 | true
37 | v140
38 | Unicode
39 |
40 |
41 | Application
42 | false
43 | v140
44 | true
45 | Unicode
46 |
47 |
48 | Application
49 | true
50 | v143
51 | Unicode
52 |
53 |
54 | Application
55 | false
56 | v143
57 | true
58 | Unicode
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | true
80 | ../include;$(IncludePath)
81 | $(SolutionDir)$(Platform)\$(Configuration)\
82 | $(Platform)\$(Configuration)\
83 |
84 |
85 | true
86 | ../include;$(IncludePath)
87 |
88 |
89 | false
90 | ../include;$(IncludePath)
91 | $(SolutionDir)$(Platform)\$(Configuration)\
92 | $(Platform)\$(Configuration)\
93 |
94 |
95 | false
96 | ../include;$(IncludePath)
97 |
98 |
99 |
100 | Level3
101 | Disabled
102 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
103 | true
104 |
105 |
106 | Console
107 | true
108 | ws2_32.lib;%(AdditionalDependencies)
109 |
110 |
111 |
112 |
113 | Level4
114 | Disabled
115 | _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
116 | true
117 | TurnOffAllWarnings
118 | stdcpp17
119 |
120 |
121 | Console
122 | true
123 | ws2_32.lib;%(AdditionalDependencies)
124 |
125 |
126 |
127 |
128 | Level3
129 | MaxSpeed
130 | true
131 | true
132 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
133 | true
134 |
135 |
136 | Console
137 | true
138 | true
139 | true
140 | ws2_32.lib;%(AdditionalDependencies)
141 |
142 |
143 |
144 |
145 | Level4
146 | MaxSpeed
147 | true
148 | true
149 | _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
150 | true
151 | TurnOffAllWarnings
152 | stdcpp17
153 |
154 |
155 | Console
156 | true
157 | true
158 | true
159 | ws2_32.lib;%(AdditionalDependencies)
160 |
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/example/example.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 30DAD98B1ECA11AC00E9F3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 30DAD98A1ECA11AC00E9F3D7 /* main.cpp */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXFileReference section */
14 | 30DAD9801ECA117100E9F3D7 /* example */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example; sourceTree = BUILT_PRODUCTS_DIR; };
15 | 30DAD98A1ECA11AC00E9F3D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
16 | 30DAD98E1ECA180B00E9F3D7 /* HTTPRequest.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HTTPRequest.hpp; sourceTree = ""; };
17 | /* End PBXFileReference section */
18 |
19 | /* Begin PBXGroup section */
20 | 30DAD9771ECA117100E9F3D7 = {
21 | isa = PBXGroup;
22 | children = (
23 | 30DAD98D1ECA11BC00E9F3D7 /* include */,
24 | 30DAD98C1ECA11B600E9F3D7 /* example */,
25 | 30DAD9811ECA117100E9F3D7 /* Products */,
26 | );
27 | sourceTree = "";
28 | };
29 | 30DAD9811ECA117100E9F3D7 /* Products */ = {
30 | isa = PBXGroup;
31 | children = (
32 | 30DAD9801ECA117100E9F3D7 /* example */,
33 | );
34 | name = Products;
35 | sourceTree = "";
36 | };
37 | 30DAD98C1ECA11B600E9F3D7 /* example */ = {
38 | isa = PBXGroup;
39 | children = (
40 | 30DAD98A1ECA11AC00E9F3D7 /* main.cpp */,
41 | );
42 | name = example;
43 | sourceTree = "";
44 | };
45 | 30DAD98D1ECA11BC00E9F3D7 /* include */ = {
46 | isa = PBXGroup;
47 | children = (
48 | 30DAD98E1ECA180B00E9F3D7 /* HTTPRequest.hpp */,
49 | );
50 | name = include;
51 | path = ../include;
52 | sourceTree = "";
53 | };
54 | /* End PBXGroup section */
55 |
56 | /* Begin PBXNativeTarget section */
57 | 30DAD97F1ECA117100E9F3D7 /* example */ = {
58 | isa = PBXNativeTarget;
59 | buildConfigurationList = 30DAD9871ECA117100E9F3D7 /* Build configuration list for PBXNativeTarget "example" */;
60 | buildPhases = (
61 | 30DAD97C1ECA117100E9F3D7 /* Sources */,
62 | );
63 | buildRules = (
64 | );
65 | dependencies = (
66 | );
67 | name = example;
68 | productName = example;
69 | productReference = 30DAD9801ECA117100E9F3D7 /* example */;
70 | productType = "com.apple.product-type.tool";
71 | };
72 | /* End PBXNativeTarget section */
73 |
74 | /* Begin PBXProject section */
75 | 30DAD9781ECA117100E9F3D7 /* Project object */ = {
76 | isa = PBXProject;
77 | attributes = {
78 | LastUpgradeCheck = 0830;
79 | ORGANIZATIONNAME = "Elviss Strazdins";
80 | TargetAttributes = {
81 | 30DAD97F1ECA117100E9F3D7 = {
82 | CreatedOnToolsVersion = 8.3.2;
83 | ProvisioningStyle = Automatic;
84 | };
85 | };
86 | };
87 | buildConfigurationList = 30DAD97B1ECA117100E9F3D7 /* Build configuration list for PBXProject "example" */;
88 | compatibilityVersion = "Xcode 3.2";
89 | developmentRegion = English;
90 | hasScannedForEncodings = 0;
91 | knownRegions = (
92 | English,
93 | en,
94 | );
95 | mainGroup = 30DAD9771ECA117100E9F3D7;
96 | productRefGroup = 30DAD9811ECA117100E9F3D7 /* Products */;
97 | projectDirPath = "";
98 | projectRoot = "";
99 | targets = (
100 | 30DAD97F1ECA117100E9F3D7 /* example */,
101 | );
102 | };
103 | /* End PBXProject section */
104 |
105 | /* Begin PBXSourcesBuildPhase section */
106 | 30DAD97C1ECA117100E9F3D7 /* Sources */ = {
107 | isa = PBXSourcesBuildPhase;
108 | buildActionMask = 2147483647;
109 | files = (
110 | 30DAD98B1ECA11AC00E9F3D7 /* main.cpp in Sources */,
111 | );
112 | runOnlyForDeploymentPostprocessing = 0;
113 | };
114 | /* End PBXSourcesBuildPhase section */
115 |
116 | /* Begin XCBuildConfiguration section */
117 | 30DAD9851ECA117100E9F3D7 /* Debug */ = {
118 | isa = XCBuildConfiguration;
119 | buildSettings = {
120 | ALWAYS_SEARCH_USER_PATHS = NO;
121 | CLANG_ANALYZER_NONNULL = YES;
122 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
123 | CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
124 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
125 | CLANG_CXX_LIBRARY = "libc++";
126 | CLANG_ENABLE_MODULES = YES;
127 | CLANG_ENABLE_OBJC_ARC = YES;
128 | CLANG_WARN_ASSIGN_ENUM = YES;
129 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
130 | CLANG_WARN_BOOL_CONVERSION = YES;
131 | CLANG_WARN_COMMA = YES;
132 | CLANG_WARN_CONSTANT_CONVERSION = YES;
133 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
134 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
135 | CLANG_WARN_EMPTY_BODY = YES;
136 | CLANG_WARN_ENUM_CONVERSION = YES;
137 | CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
138 | CLANG_WARN_INFINITE_RECURSION = YES;
139 | CLANG_WARN_INT_CONVERSION = YES;
140 | CLANG_WARN_OBJC_ROOT_CLASS = YES;
141 | CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
142 | CLANG_WARN_STRICT_PROTOTYPES = YES;
143 | CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
144 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
145 | CLANG_WARN_UNREACHABLE_CODE = YES;
146 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
147 | CODE_SIGN_IDENTITY = "-";
148 | COPY_PHASE_STRIP = NO;
149 | DEBUG_INFORMATION_FORMAT = dwarf;
150 | ENABLE_STRICT_OBJC_MSGSEND = YES;
151 | ENABLE_TESTABILITY = YES;
152 | GCC_DYNAMIC_NO_PIC = NO;
153 | GCC_NO_COMMON_BLOCKS = YES;
154 | GCC_OPTIMIZATION_LEVEL = 0;
155 | GCC_PREPROCESSOR_DEFINITIONS = (
156 | "DEBUG=1",
157 | "$(inherited)",
158 | );
159 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
160 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
161 | GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
162 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
163 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
164 | GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
165 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
166 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
167 | GCC_WARN_PEDANTIC = YES;
168 | GCC_WARN_SHADOW = YES;
169 | GCC_WARN_SIGN_COMPARE = YES;
170 | GCC_WARN_UNDECLARED_SELECTOR = YES;
171 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
172 | GCC_WARN_UNKNOWN_PRAGMAS = YES;
173 | GCC_WARN_UNUSED_FUNCTION = YES;
174 | GCC_WARN_UNUSED_LABEL = YES;
175 | GCC_WARN_UNUSED_PARAMETER = YES;
176 | GCC_WARN_UNUSED_VARIABLE = YES;
177 | HEADER_SEARCH_PATHS = ../include;
178 | MACOSX_DEPLOYMENT_TARGET = 10.12;
179 | MTL_ENABLE_DEBUG_INFO = YES;
180 | ONLY_ACTIVE_ARCH = YES;
181 | SDKROOT = macosx;
182 | };
183 | name = Debug;
184 | };
185 | 30DAD9861ECA117100E9F3D7 /* Release */ = {
186 | isa = XCBuildConfiguration;
187 | buildSettings = {
188 | ALWAYS_SEARCH_USER_PATHS = NO;
189 | CLANG_ANALYZER_NONNULL = YES;
190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
191 | CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
192 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
193 | CLANG_CXX_LIBRARY = "libc++";
194 | CLANG_ENABLE_MODULES = YES;
195 | CLANG_ENABLE_OBJC_ARC = YES;
196 | CLANG_WARN_ASSIGN_ENUM = YES;
197 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
198 | CLANG_WARN_BOOL_CONVERSION = YES;
199 | CLANG_WARN_COMMA = YES;
200 | CLANG_WARN_CONSTANT_CONVERSION = YES;
201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
203 | CLANG_WARN_EMPTY_BODY = YES;
204 | CLANG_WARN_ENUM_CONVERSION = YES;
205 | CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
206 | CLANG_WARN_INFINITE_RECURSION = YES;
207 | CLANG_WARN_INT_CONVERSION = YES;
208 | CLANG_WARN_OBJC_ROOT_CLASS = YES;
209 | CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
210 | CLANG_WARN_STRICT_PROTOTYPES = YES;
211 | CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
212 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
213 | CLANG_WARN_UNREACHABLE_CODE = YES;
214 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
215 | CODE_SIGN_IDENTITY = "-";
216 | COPY_PHASE_STRIP = NO;
217 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
218 | ENABLE_NS_ASSERTIONS = NO;
219 | ENABLE_STRICT_OBJC_MSGSEND = YES;
220 | GCC_NO_COMMON_BLOCKS = YES;
221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
222 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
223 | GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
224 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
225 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
226 | GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
227 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
228 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
229 | GCC_WARN_PEDANTIC = YES;
230 | GCC_WARN_SHADOW = YES;
231 | GCC_WARN_SIGN_COMPARE = YES;
232 | GCC_WARN_UNDECLARED_SELECTOR = YES;
233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
234 | GCC_WARN_UNKNOWN_PRAGMAS = YES;
235 | GCC_WARN_UNUSED_FUNCTION = YES;
236 | GCC_WARN_UNUSED_LABEL = YES;
237 | GCC_WARN_UNUSED_PARAMETER = YES;
238 | GCC_WARN_UNUSED_VARIABLE = YES;
239 | HEADER_SEARCH_PATHS = ../include;
240 | MACOSX_DEPLOYMENT_TARGET = 10.12;
241 | MTL_ENABLE_DEBUG_INFO = NO;
242 | SDKROOT = macosx;
243 | };
244 | name = Release;
245 | };
246 | 30DAD9881ECA117100E9F3D7 /* Debug */ = {
247 | isa = XCBuildConfiguration;
248 | buildSettings = {
249 | PRODUCT_NAME = "$(TARGET_NAME)";
250 | };
251 | name = Debug;
252 | };
253 | 30DAD9891ECA117100E9F3D7 /* Release */ = {
254 | isa = XCBuildConfiguration;
255 | buildSettings = {
256 | PRODUCT_NAME = "$(TARGET_NAME)";
257 | };
258 | name = Release;
259 | };
260 | /* End XCBuildConfiguration section */
261 |
262 | /* Begin XCConfigurationList section */
263 | 30DAD97B1ECA117100E9F3D7 /* Build configuration list for PBXProject "example" */ = {
264 | isa = XCConfigurationList;
265 | buildConfigurations = (
266 | 30DAD9851ECA117100E9F3D7 /* Debug */,
267 | 30DAD9861ECA117100E9F3D7 /* Release */,
268 | );
269 | defaultConfigurationIsVisible = 0;
270 | defaultConfigurationName = Release;
271 | };
272 | 30DAD9871ECA117100E9F3D7 /* Build configuration list for PBXNativeTarget "example" */ = {
273 | isa = XCConfigurationList;
274 | buildConfigurations = (
275 | 30DAD9881ECA117100E9F3D7 /* Debug */,
276 | 30DAD9891ECA117100E9F3D7 /* Release */,
277 | );
278 | defaultConfigurationIsVisible = 0;
279 | defaultConfigurationName = Release;
280 | };
281 | /* End XCConfigurationList section */
282 | };
283 | rootObject = 30DAD9781ECA117100E9F3D7 /* Project object */;
284 | }
285 |
--------------------------------------------------------------------------------
/example/example.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // HTTPRequest
3 | //
4 |
5 | #include
6 | #include
7 | #include "HTTPRequest.hpp"
8 |
9 | int main(int argc, const char* argv[])
10 | {
11 | try
12 | {
13 | std::string uri;
14 | std::string method = "GET";
15 | std::string arguments;
16 | std::string output;
17 | auto protocol = http::InternetProtocol::v4;
18 |
19 | for (int i = 1; i < argc; ++i)
20 | {
21 | const auto arg = std::string{argv[i]};
22 |
23 | if (arg == "--help")
24 | {
25 | std::cout << "example --url [--protocol ] [--method ] [--arguments ] [--output