add skeleton and broken http client code.

GET returns "Resource temporarily unavailable" errors...
This commit is contained in:
Benjamin Sergeant
2019-02-14 10:14:57 -08:00
parent 49077f8f44
commit 2a17cad1bf
6 changed files with 171 additions and 0 deletions

1
examples/http_client/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build

View File

@ -0,0 +1,22 @@
#
# Author: Benjamin Sergeant
# Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
#
cmake_minimum_required (VERSION 3.4.1)
project (http_client)
set (CMAKE_CXX_STANDARD 14)
option(USE_TLS "Add TLS support" ON)
add_subdirectory(${PROJECT_SOURCE_DIR}/../.. ixwebsocket)
add_executable(http_client http_client.cpp)
if (APPLE AND USE_TLS)
target_link_libraries(http_client "-framework foundation" "-framework security")
endif()
target_link_libraries(http_client ixwebsocket)
install(TARGETS http_client DESTINATION bin)

View File

@ -0,0 +1,32 @@
/*
* http_client.cpp
* Author: Benjamin Sergeant
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
*/
#include <iostream>
#include <sstream>
#include <ixwebsocket/IXHttpClient.h>
using namespace ix;
void run(const std::string& url)
{
HttpClient httpClient;
httpClient.get(url);
}
int main(int argc, char** argv)
{
if (argc != 2)
{
std::cerr << "Usage: ws_connect <url>" << std::endl;
return 1;
}
std::string url = argv[1];
Socket::init();
run(url);
return 0;
}