Skip to content

Commit e8bc018

Browse files
committed
Merge branch 'master' of github.com:cpp-netlib/cpp-netlib
At this point we're getting ready for a pull of the Boost exodus changes that are in deanberris/cpp-netlib.
2 parents 579adb8 + 702e094 commit e8bc018

File tree

8 files changed

+259
-19
lines changed

8 files changed

+259
-19
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
*.cmake
21
*.swp
32
*.pyc
43
CMakeCache.txt

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
cmake_minimum_required(VERSION 2.8)
88
project(CPP-NETLIB)
9+
10+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
11+
find_package( ICU )
12+
913
set(Boost_USE_STATIC_LIBS ON)
1014
set(Boost_USE_MULTITHREADED ON)
1115
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options )
@@ -33,6 +37,10 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
3337
else()
3438
message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).")
3539
endif()
40+
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
41+
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
42+
set(CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
43+
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
3644
endif()
3745

3846
if (Boost_FOUND)

FindICU.cmake

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Finds the International Components for Unicode (ICU) Library
2+
#
3+
# ICU_FOUND - True if ICU found.
4+
# ICU_I18N_FOUND - True if ICU's internationalization library found.
5+
# ICU_INCLUDE_DIRS - Directory to include to get ICU headers
6+
# Note: always include ICU headers as, e.g.,
7+
# unicode/utypes.h
8+
# ICU_LIBRARIES - Libraries to link against for the common ICU
9+
# ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation
10+
# (note: in addition to ICU_LIBRARIES)
11+
12+
# Look for the header file.
13+
find_path(
14+
ICU_INCLUDE_DIR
15+
NAMES unicode/utypes.h
16+
DOC "Include directory for the ICU library")
17+
mark_as_advanced(ICU_INCLUDE_DIR)
18+
19+
# Look for the library.
20+
find_library(
21+
ICU_LIBRARY
22+
NAMES icuuc cygicuuc cygicuuc32
23+
DOC "Libraries to link against for the common parts of ICU")
24+
mark_as_advanced(ICU_LIBRARY)
25+
26+
# Copy the results to the output variables.
27+
if(ICU_INCLUDE_DIR AND ICU_LIBRARY)
28+
set(ICU_FOUND 1)
29+
set(ICU_LIBRARIES ${ICU_LIBRARY})
30+
set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
31+
32+
set(ICU_VERSION 0)
33+
set(ICU_MAJOR_VERSION 0)
34+
set(ICU_MINOR_VERSION 0)
35+
if (EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h")
36+
FILE(READ "${ICU_INCLUDE_DIR}/unicode/uvernum.h" _ICU_VERSION_CONENTS)
37+
else()
38+
FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS)
39+
endif()
40+
41+
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
42+
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
43+
44+
set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
45+
46+
# Look for the ICU internationalization libraries
47+
find_library(
48+
ICU_I18N_LIBRARY
49+
NAMES icuin icui18n cygicuin cygicuin32
50+
DOC "Libraries to link against for ICU internationalization")
51+
mark_as_advanced(ICU_I18N_LIBRARY)
52+
if (ICU_I18N_LIBRARY)
53+
set(ICU_I18N_FOUND 1)
54+
set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
55+
else (ICU_I18N_LIBRARY)
56+
set(ICU_I18N_FOUND 0)
57+
set(ICU_I18N_LIBRARIES)
58+
endif (ICU_I18N_LIBRARY)
59+
60+
# Look for the ICU data libraries
61+
find_library(
62+
ICU_DATA_LIBRARY
63+
NAMES icudata cygicudata cygicudata32
64+
DOC "Libraries to link against for ICU data")
65+
mark_as_advanced(ICU_DATA_LIBRARY)
66+
if (ICU_DATA_LIBRARY)
67+
set(ICU_DATA_FOUND 1)
68+
set(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY})
69+
else (ICU_DATA_LIBRARY)
70+
set(ICU_DATA_FOUND 0)
71+
set(ICU_DATA_LIBRARIES)
72+
endif (ICU_DATA_LIBRARY)
73+
else(ICU_INCLUDE_DIR AND ICU_LIBRARY)
74+
set(ICU_FOUND 0)
75+
set(ICU_I18N_FOUND 0)
76+
set(ICU_DATA_FOUND 0)
77+
set(ICU_LIBRARIES)
78+
set(ICU_I18N_LIBRARIES)
79+
set(ICU_DATA_LIBRARIES)
80+
set(ICU_INCLUDE_DIRS)
81+
set(ICU_VERSION)
82+
set(ICU_MAJOR_VERSION)
83+
set(ICU_MINOR_VERSION)
84+
endif(ICU_INCLUDE_DIR AND ICU_LIBRARY)
85+
86+
IF(ICU_FOUND)
87+
IF( NOT ICU_FIND_QUIETLY )
88+
MESSAGE( STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
89+
MESSAGE( STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
90+
ENDIF( NOT ICU_FIND_QUIETLY )
91+
ELSE(ICU_FOUND)
92+
IF(ICU_FIND_REQUIRED)
93+
MESSAGE( FATAL_ERROR "Could not find ICU" )
94+
ELSE(ICU_FIND_REQUIRED)
95+
MESSAGE( STATUS "Optional package ICU was not found" )
96+
ENDIF(ICU_FIND_REQUIRED)
97+
ENDIF(ICU_FOUND)

include/network/uri/uri.ipp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,36 @@ struct uri_grammar : qi::grammar<
108108
;
109109

110110
ipv6address %= qi::raw[
111-
qi::repeat(6)[h16 >> ':'] >> ls32
112-
| "::" >> qi::repeat(5)[h16 >> ':'] >> ls32
113-
| qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32
114-
| qi::raw[ +(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32
115-
| qi::raw[qi::repeat(2)[*(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32
116-
| qi::raw[qi::repeat(3)[*(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32
117-
| qi::raw[qi::repeat(4)[*(h16 >> ':')] >> h16] >> "::" >> ls32
118-
| qi::raw[qi::repeat(5)[*(h16 >> ':')] >> h16] >> "::" >> h16
119-
| qi::raw[qi::repeat(6)[*(h16 >> ':')] >> h16] >> "::"
111+
qi::repeat(6)[h16 >> ':'] >> ls32
112+
| "::" >> qi::repeat(5)[h16 >> ':'] >> ls32
113+
| - qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32
114+
| - qi::raw[ h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32
115+
| - qi::raw[ h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32
116+
| - qi::raw[ h16] >> "::" >> h16 >> ':' >> ls32
117+
| - qi::raw[ h16] >> "::" >> ls32
118+
| - qi::raw[ h16] >> "::" >> h16
119+
| - qi::raw[ h16] >> "::"
120+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32
121+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32
122+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32
123+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> ls32
124+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> h16
125+
| - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::"
126+
| - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32
127+
| - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32
128+
| - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> ls32
129+
| - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> h16
130+
| - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::"
131+
| - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32
132+
| - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> ls32
133+
| - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> h16
134+
| - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::"
135+
| - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::" >> ls32
136+
| - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::" >> h16
137+
| - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::"
138+
| - qi::raw[qi::repeat(5)[(h16 >> ':')] >> h16] >> "::" >> h16
139+
| - qi::raw[qi::repeat(5)[(h16 >> ':')] >> h16] >> "::"
140+
| - qi::raw[qi::repeat(6)[(h16 >> ':')] >> h16] >> "::"
120141
];
121142

122143
// ls32 = ( h16 ":" h16 ) / IPv4address

libs/mime/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set ( Boost_USE_MULTITHREADED ON )
55

66
if ( Boost_FOUND )
77
add_executable ( mime-roundtrip mime-roundtrip.cpp )
8-
target_link_libraries ( mime-roundtrip ${Boost_LIBRARIES} )
8+
target_link_libraries ( mime-roundtrip )
99
add_test ( mime-roundtrip mime-roundtrip )
1010
endif ()
1111

libs/network/test/http/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if (Boost_FOUND)
3636
)
3737
target_link_libraries(cpp-netlib-http-${test}
3838
${Boost_LIBRARIES}
39+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
3940
${CMAKE_THREAD_LIBS_INIT}
4041
cppnetlib-message
4142
cppnetlib-message-wrappers
@@ -65,6 +66,7 @@ if (Boost_FOUND)
6566
add_executable(cpp-netlib-http-${test} ${test}.cpp)
6667
target_link_libraries(cpp-netlib-http-${test}
6768
${Boost_LIBRARIES}
69+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
6870
${CMAKE_THREAD_LIBS_INIT}
6971
cppnetlib-constants
7072
cppnetlib-uri
@@ -96,6 +98,7 @@ if (Boost_FOUND)
9698
add_executable(cpp-netlib-http-${test} ${test}.cpp)
9799
target_link_libraries(cpp-netlib-http-${test}
98100
${Boost_LIBRARIES}
101+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
99102
${CMAKE_THREAD_LIBS_INIT}
100103
cppnetlib-constants
101104
cppnetlib-uri

libs/network/test/uri/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (Boost_FOUND)
2525
add_executable(cpp-netlib-${test} ${test}.cpp)
2626
add_dependencies(cpp-netlib-${test} cppnetlib-uri)
2727
target_link_libraries(cpp-netlib-${test}
28-
${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri)
28+
${Boost_LIBRARIES} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri)
2929
if (OPENSSL_FOUND)
3030
target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES})
3131
endif()

libs/network/test/uri/uri_test.cpp

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,125 @@ BOOST_AUTO_TEST_CASE(ipv6_address_test_2) {
273273
BOOST_CHECK_EQUAL(network::path(instance), "/");
274274
}
275275

276-
//BOOST_AUTO_TEST_CASE(ipv6_loopback_test) {
277-
// network::uri instance("http://[::1]/");
278-
// BOOST_REQUIRE(network::valid(instance));
279-
// BOOST_CHECK_EQUAL(network::scheme(instance), "http");
280-
// BOOST_CHECK_EQUAL(network::host(instance), "[::1]");
281-
// BOOST_CHECK_EQUAL(network::path(instance), "/");
282-
//}
276+
BOOST_AUTO_TEST_CASE(ipv6_address_test_3) {
277+
network::uri instance("http://[2001:db8:85a3:0:0:8a2e:370:7334]/");
278+
BOOST_REQUIRE(network::valid(instance));
279+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
280+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8:85a3:0:0:8a2e:370:7334]");
281+
BOOST_CHECK_EQUAL(network::path(instance), "/");
282+
}
283+
284+
BOOST_AUTO_TEST_CASE(ipv6_address_test_4) {
285+
network::uri instance("http://[2001:db8:85a3::8a2e:370:7334]/");
286+
BOOST_REQUIRE(network::valid(instance));
287+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
288+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8:85a3::8a2e:370:7334]");
289+
BOOST_CHECK_EQUAL(network::path(instance), "/");
290+
}
291+
292+
BOOST_AUTO_TEST_CASE(ipv6_address_test_5) {
293+
network::uri instance("http://[2001:0db8:0000:0000:0000:0000:1428:57ab]/");
294+
BOOST_REQUIRE(network::valid(instance));
295+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
296+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0000:0000:0000:0000:1428:57ab]");
297+
BOOST_CHECK_EQUAL(network::path(instance), "/");
298+
}
299+
300+
BOOST_AUTO_TEST_CASE(ipv6_address_test_6) {
301+
network::uri instance("http://[2001:0db8:0000:0000:0000::1428:57ab]/");
302+
BOOST_REQUIRE(network::valid(instance));
303+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
304+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0000:0000:0000::1428:57ab]");
305+
BOOST_CHECK_EQUAL(network::path(instance), "/");
306+
}
307+
308+
BOOST_AUTO_TEST_CASE(ipv6_address_test_7) {
309+
network::uri instance("http://[2001:0db8:0:0:0:0:1428:57ab]/");
310+
BOOST_REQUIRE(network::valid(instance));
311+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
312+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0:0:0:0:1428:57ab]");
313+
BOOST_CHECK_EQUAL(network::path(instance), "/");
314+
}
315+
316+
BOOST_AUTO_TEST_CASE(ipv6_address_test_8) {
317+
network::uri instance("http://[2001:0db8:0:0::1428:57ab]/");
318+
BOOST_REQUIRE(network::valid(instance));
319+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
320+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0:0::1428:57ab]");
321+
BOOST_CHECK_EQUAL(network::path(instance), "/");
322+
}
323+
324+
BOOST_AUTO_TEST_CASE(ipv6_address_test_9) {
325+
network::uri instance("http://[2001:0db8::1428:57ab]/");
326+
BOOST_REQUIRE(network::valid(instance));
327+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
328+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8::1428:57ab]");
329+
BOOST_CHECK_EQUAL(network::path(instance), "/");
330+
}
331+
332+
BOOST_AUTO_TEST_CASE(ipv6_address_test_10) {
333+
network::uri instance("http://[2001:db8::1428:57ab]/");
334+
BOOST_REQUIRE(network::valid(instance));
335+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
336+
BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8::1428:57ab]");
337+
BOOST_CHECK_EQUAL(network::path(instance), "/");
338+
}
339+
340+
BOOST_AUTO_TEST_CASE(ipv6_address_test_11) {
341+
network::uri instance("http://[::ffff:0c22:384e]/");
342+
BOOST_REQUIRE(network::valid(instance));
343+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
344+
BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:0c22:384e]");
345+
BOOST_CHECK_EQUAL(network::path(instance), "/");
346+
}
347+
348+
BOOST_AUTO_TEST_CASE(ipv6_address_test_12) {
349+
network::uri instance("http://[fe80::]/");
350+
BOOST_REQUIRE(network::valid(instance));
351+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
352+
BOOST_CHECK_EQUAL(network::host(instance), "[fe80::]");
353+
BOOST_CHECK_EQUAL(network::path(instance), "/");
354+
}
355+
356+
BOOST_AUTO_TEST_CASE(ipv6_address_test_13) {
357+
network::uri instance("http://[::ffff:c000:280]/");
358+
BOOST_REQUIRE(network::valid(instance));
359+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
360+
BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:c000:280]");
361+
BOOST_CHECK_EQUAL(network::path(instance), "/");
362+
}
363+
364+
BOOST_AUTO_TEST_CASE(ipv6_loopback_test) {
365+
network::uri instance("http://[::1]/");
366+
BOOST_REQUIRE(network::valid(instance));
367+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
368+
BOOST_CHECK_EQUAL(network::host(instance), "[::1]");
369+
BOOST_CHECK_EQUAL(network::path(instance), "/");
370+
}
371+
372+
BOOST_AUTO_TEST_CASE(ipv6_loopback_test_1) {
373+
network::uri instance("http://[0000:0000:0000:0000:0000:0000:0000:0001]/");
374+
BOOST_REQUIRE(network::valid(instance));
375+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
376+
BOOST_CHECK_EQUAL(network::host(instance), "[0000:0000:0000:0000:0000:0000:0000:0001]");
377+
BOOST_CHECK_EQUAL(network::path(instance), "/");
378+
}
379+
380+
BOOST_AUTO_TEST_CASE(ipv6_v4inv6_test_1) {
381+
network::uri instance("http://[::ffff:12.34.56.78]/");
382+
BOOST_REQUIRE(network::valid(instance));
383+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
384+
BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:12.34.56.78]");
385+
BOOST_CHECK_EQUAL(network::path(instance), "/");
386+
}
387+
388+
BOOST_AUTO_TEST_CASE(ipv6_v4inv6_test_2) {
389+
network::uri instance("http://[::ffff:192.0.2.128]/");
390+
BOOST_REQUIRE(network::valid(instance));
391+
BOOST_CHECK_EQUAL(network::scheme(instance), "http");
392+
BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:192.0.2.128]");
393+
BOOST_CHECK_EQUAL(network::path(instance), "/");
394+
}
283395

284396
BOOST_AUTO_TEST_CASE(ftp_test) {
285397
network::uri instance("ftp://[email protected]/");

0 commit comments

Comments
 (0)