couchbase 3.0.0.beta.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1007) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +74 -6
  3. data/ext/CMakeLists.txt +96 -136
  4. data/ext/build_config.hxx.in +3 -1
  5. data/ext/build_version.hxx.in +11 -7
  6. data/ext/cmake/Backtrace.cmake +35 -0
  7. data/ext/cmake/BuildTracing.cmake +6 -0
  8. data/ext/cmake/Cache.cmake +29 -0
  9. data/ext/cmake/CompilerWarnings.cmake +84 -0
  10. data/ext/cmake/PreventInSourceBuilds.cmake +21 -0
  11. data/ext/cmake/Sanitizers.cmake +66 -0
  12. data/ext/cmake/StandardProjectSettings.cmake +40 -0
  13. data/ext/cmake/StaticAnalyzers.cmake +37 -0
  14. data/ext/cmake/Testing.cmake +49 -0
  15. data/ext/cmake/ThirdPartyDependencies.cmake +20 -0
  16. data/ext/cmake/VersionInfo.cmake +37 -0
  17. data/ext/couchbase/bucket.hxx +252 -41
  18. data/ext/couchbase/capabilities.hxx +117 -0
  19. data/ext/couchbase/cbcrypto/cbcrypto.cc +15 -15
  20. data/ext/couchbase/cbsasl/client.h +1 -1
  21. data/ext/couchbase/cluster.hxx +150 -11
  22. data/ext/couchbase/cluster_options.hxx +4 -1
  23. data/ext/couchbase/collections_manifest.hxx +1 -1
  24. data/ext/couchbase/configuration.hxx +245 -67
  25. data/ext/couchbase/couchbase.cxx +3567 -1223
  26. data/ext/couchbase/diagnostics.hxx +248 -0
  27. data/ext/couchbase/document_id.hxx +4 -2
  28. data/ext/couchbase/error_context/analytics.hxx +46 -0
  29. data/ext/couchbase/error_context/http.hxx +44 -0
  30. data/ext/couchbase/error_context/key_value.hxx +47 -0
  31. data/ext/couchbase/error_context/query.hxx +46 -0
  32. data/ext/couchbase/error_context/search.hxx +47 -0
  33. data/ext/couchbase/error_context/view.hxx +47 -0
  34. data/ext/couchbase/error_map.hxx +203 -3
  35. data/ext/couchbase/errors.hxx +19 -4
  36. data/ext/couchbase/io/dns_client.hxx +9 -9
  37. data/ext/couchbase/io/dns_codec.hxx +2 -3
  38. data/ext/couchbase/io/dns_config.hxx +1 -1
  39. data/ext/couchbase/io/dns_message.hxx +1 -1
  40. data/ext/couchbase/io/http_command.hxx +29 -9
  41. data/ext/couchbase/io/http_context.hxx +37 -0
  42. data/ext/couchbase/io/http_message.hxx +10 -1
  43. data/ext/couchbase/io/http_parser.hxx +3 -1
  44. data/ext/couchbase/io/http_session.hxx +131 -47
  45. data/ext/couchbase/io/http_session_manager.hxx +149 -7
  46. data/ext/couchbase/io/mcbp_command.hxx +121 -52
  47. data/ext/couchbase/io/mcbp_context.hxx +37 -0
  48. data/ext/couchbase/io/mcbp_message.hxx +1 -1
  49. data/ext/couchbase/io/mcbp_parser.hxx +1 -1
  50. data/ext/couchbase/io/mcbp_session.hxx +411 -101
  51. data/ext/couchbase/io/query_cache.hxx +61 -0
  52. data/ext/couchbase/io/retry_action.hxx +30 -0
  53. data/ext/couchbase/io/retry_context.hxx +38 -0
  54. data/ext/couchbase/io/retry_orchestrator.hxx +112 -0
  55. data/ext/couchbase/io/retry_reason.hxx +235 -0
  56. data/ext/couchbase/io/retry_strategy.hxx +156 -0
  57. data/ext/couchbase/io/streams.hxx +62 -11
  58. data/ext/couchbase/mutation_token.hxx +1 -1
  59. data/ext/couchbase/operations.hxx +19 -1
  60. data/ext/couchbase/operations/analytics_dataset_create.hxx +21 -13
  61. data/ext/couchbase/operations/analytics_dataset_drop.hxx +19 -10
  62. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +18 -11
  63. data/ext/couchbase/operations/analytics_dataverse_create.hxx +20 -12
  64. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +19 -12
  65. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +19 -11
  66. data/ext/couchbase/operations/analytics_index_create.hxx +19 -12
  67. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -11
  68. data/ext/couchbase/operations/analytics_index_get_all.hxx +16 -9
  69. data/ext/couchbase/operations/analytics_link_connect.hxx +17 -10
  70. data/ext/couchbase/operations/analytics_link_disconnect.hxx +19 -12
  71. data/ext/couchbase/operations/bucket_create.hxx +45 -15
  72. data/ext/couchbase/operations/bucket_drop.hxx +12 -10
  73. data/ext/couchbase/operations/bucket_flush.hxx +11 -10
  74. data/ext/couchbase/operations/bucket_get.hxx +17 -11
  75. data/ext/couchbase/operations/bucket_get_all.hxx +16 -8
  76. data/ext/couchbase/operations/bucket_settings.hxx +59 -4
  77. data/ext/couchbase/operations/bucket_update.hxx +44 -15
  78. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +9 -8
  79. data/ext/couchbase/operations/collection_create.hxx +23 -14
  80. data/ext/couchbase/operations/collection_drop.hxx +21 -14
  81. data/ext/couchbase/operations/collections_manifest_get.hxx +66 -0
  82. data/ext/couchbase/operations/design_document.hxx +1 -1
  83. data/ext/couchbase/operations/document_analytics.hxx +46 -18
  84. data/ext/couchbase/operations/document_append.hxx +72 -0
  85. data/ext/couchbase/operations/document_decrement.hxx +10 -12
  86. data/ext/couchbase/operations/document_exists.hxx +9 -8
  87. data/ext/couchbase/operations/document_get.hxx +10 -11
  88. data/ext/couchbase/operations/document_get_and_lock.hxx +9 -11
  89. data/ext/couchbase/operations/document_get_and_touch.hxx +9 -11
  90. data/ext/couchbase/operations/document_get_projected.hxx +26 -16
  91. data/ext/couchbase/operations/document_increment.hxx +10 -12
  92. data/ext/couchbase/operations/document_insert.hxx +10 -12
  93. data/ext/couchbase/operations/document_lookup_in.hxx +13 -10
  94. data/ext/couchbase/operations/document_mutate_in.hxx +22 -13
  95. data/ext/couchbase/operations/document_prepend.hxx +72 -0
  96. data/ext/couchbase/operations/document_query.hxx +132 -27
  97. data/ext/couchbase/operations/document_remove.hxx +12 -12
  98. data/ext/couchbase/operations/document_replace.hxx +10 -12
  99. data/ext/couchbase/operations/document_search.hxx +53 -16
  100. data/ext/couchbase/operations/document_touch.hxx +9 -11
  101. data/ext/couchbase/operations/document_unlock.hxx +9 -11
  102. data/ext/couchbase/operations/document_upsert.hxx +10 -12
  103. data/ext/couchbase/operations/document_view.hxx +31 -14
  104. data/ext/couchbase/operations/group_drop.hxx +72 -0
  105. data/ext/couchbase/operations/group_get.hxx +80 -0
  106. data/ext/couchbase/operations/group_get_all.hxx +77 -0
  107. data/ext/couchbase/operations/group_upsert.hxx +125 -0
  108. data/ext/couchbase/operations/http_noop.hxx +78 -0
  109. data/ext/couchbase/operations/mcbp_noop.hxx +55 -0
  110. data/ext/couchbase/operations/query_index_build_deferred.hxx +18 -11
  111. data/ext/couchbase/operations/query_index_create.hxx +32 -15
  112. data/ext/couchbase/operations/query_index_drop.hxx +30 -13
  113. data/ext/couchbase/operations/query_index_get_all.hxx +26 -9
  114. data/ext/couchbase/operations/rbac.hxx +276 -0
  115. data/ext/couchbase/operations/role_get_all.hxx +77 -0
  116. data/ext/couchbase/operations/scope_create.hxx +24 -13
  117. data/ext/couchbase/operations/scope_drop.hxx +20 -13
  118. data/ext/couchbase/operations/scope_get_all.hxx +18 -12
  119. data/ext/couchbase/operations/search_get_stats.hxx +60 -0
  120. data/ext/couchbase/operations/search_index.hxx +1 -1
  121. data/ext/couchbase/operations/search_index_analyze_document.hxx +28 -15
  122. data/ext/couchbase/operations/search_index_control_ingest.hxx +26 -13
  123. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +26 -13
  124. data/ext/couchbase/operations/search_index_control_query.hxx +26 -13
  125. data/ext/couchbase/operations/search_index_drop.hxx +24 -11
  126. data/ext/couchbase/operations/search_index_get.hxx +24 -11
  127. data/ext/couchbase/operations/search_index_get_all.hxx +15 -8
  128. data/ext/couchbase/operations/search_index_get_documents_count.hxx +45 -25
  129. data/ext/couchbase/operations/search_index_get_stats.hxx +88 -0
  130. data/ext/couchbase/operations/search_index_upsert.hxx +25 -12
  131. data/ext/couchbase/operations/user_drop.hxx +73 -0
  132. data/ext/couchbase/operations/user_get.hxx +81 -0
  133. data/ext/couchbase/operations/user_get_all.hxx +78 -0
  134. data/ext/couchbase/operations/user_upsert.hxx +132 -0
  135. data/ext/couchbase/operations/view_index_drop.hxx +10 -9
  136. data/ext/couchbase/operations/view_index_get.hxx +17 -10
  137. data/ext/couchbase/operations/view_index_get_all.hxx +17 -10
  138. data/ext/couchbase/operations/view_index_upsert.hxx +11 -10
  139. data/ext/couchbase/origin.hxx +49 -18
  140. data/ext/couchbase/platform/backtrace.c +189 -0
  141. data/ext/couchbase/platform/backtrace.h +54 -0
  142. data/ext/couchbase/platform/terminate_handler.cc +130 -0
  143. data/ext/couchbase/platform/terminate_handler.h +36 -0
  144. data/ext/couchbase/protocol/client_opcode.hxx +407 -39
  145. data/ext/couchbase/protocol/client_request.hxx +3 -2
  146. data/ext/couchbase/protocol/client_response.hxx +21 -18
  147. data/ext/couchbase/protocol/cmd_append.hxx +145 -0
  148. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +7 -4
  149. data/ext/couchbase/protocol/cmd_decrement.hxx +1 -1
  150. data/ext/couchbase/protocol/cmd_exists.hxx +2 -1
  151. data/ext/couchbase/protocol/cmd_get.hxx +2 -2
  152. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +1 -1
  153. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +1 -1
  154. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +9 -2
  155. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +7 -7
  156. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +1 -1
  157. data/ext/couchbase/protocol/cmd_get_error_map.hxx +1 -1
  158. data/ext/couchbase/protocol/cmd_hello.hxx +12 -3
  159. data/ext/couchbase/protocol/cmd_increment.hxx +1 -1
  160. data/ext/couchbase/protocol/cmd_info.hxx +1 -1
  161. data/ext/couchbase/protocol/cmd_insert.hxx +1 -1
  162. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -4
  163. data/ext/couchbase/protocol/cmd_mutate_in.hxx +50 -9
  164. data/ext/couchbase/protocol/cmd_noop.hxx +82 -0
  165. data/ext/couchbase/protocol/cmd_prepend.hxx +145 -0
  166. data/ext/couchbase/protocol/cmd_remove.hxx +1 -1
  167. data/ext/couchbase/protocol/cmd_replace.hxx +1 -1
  168. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +1 -1
  169. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +1 -1
  170. data/ext/couchbase/protocol/cmd_sasl_step.hxx +1 -1
  171. data/ext/couchbase/protocol/cmd_select_bucket.hxx +1 -1
  172. data/ext/couchbase/protocol/cmd_touch.hxx +1 -1
  173. data/ext/couchbase/protocol/cmd_unlock.hxx +1 -1
  174. data/ext/couchbase/protocol/cmd_upsert.hxx +1 -1
  175. data/ext/couchbase/protocol/datatype.hxx +1 -1
  176. data/ext/couchbase/protocol/durability_level.hxx +17 -1
  177. data/ext/couchbase/protocol/enhanced_error_info.hxx +28 -0
  178. data/ext/couchbase/protocol/frame_info_id.hxx +1 -1
  179. data/ext/couchbase/protocol/hello_feature.hxx +10 -1
  180. data/ext/couchbase/protocol/magic.hxx +7 -7
  181. data/ext/couchbase/protocol/server_opcode.hxx +3 -3
  182. data/ext/couchbase/protocol/server_request.hxx +1 -1
  183. data/ext/couchbase/protocol/status.hxx +71 -61
  184. data/ext/couchbase/protocol/unsigned_leb128.h +2 -2
  185. data/ext/couchbase/service_type.hxx +3 -3
  186. data/ext/couchbase/timeout_defaults.hxx +1 -1
  187. data/ext/couchbase/utils/byteswap.hxx +1 -1
  188. data/ext/couchbase/utils/connection_string.hxx +32 -5
  189. data/ext/couchbase/version.hxx +19 -5
  190. data/ext/extconf.rb +61 -43
  191. data/ext/test/CMakeLists.txt +5 -0
  192. data/ext/test/test_helper.hxx +141 -0
  193. data/ext/test/test_helper_native.hxx +56 -0
  194. data/ext/test/test_helper_ruby.hxx +72 -0
  195. data/ext/test/test_native_binary_operations.cxx +186 -0
  196. data/ext/test/test_native_diagnostics.cxx +436 -0
  197. data/ext/test/test_native_trivial_crud.cxx +83 -0
  198. data/ext/test/test_ruby_trivial_crud.cxx +35 -0
  199. data/ext/test/test_ruby_trivial_query.cxx +34 -0
  200. data/ext/third_party/asio/asio/include/asio.hpp +35 -0
  201. data/ext/third_party/asio/asio/include/asio/any_io_executor.hpp +71 -0
  202. data/ext/third_party/asio/asio/include/asio/associated_allocator.hpp +1 -7
  203. data/ext/third_party/asio/asio/include/asio/associated_executor.hpp +36 -19
  204. data/ext/third_party/asio/asio/include/asio/async_result.hpp +1 -8
  205. data/ext/third_party/asio/asio/include/asio/awaitable.hpp +14 -4
  206. data/ext/third_party/asio/asio/include/asio/basic_datagram_socket.hpp +12 -7
  207. data/ext/third_party/asio/asio/include/asio/basic_deadline_timer.hpp +4 -4
  208. data/ext/third_party/asio/asio/include/asio/basic_raw_socket.hpp +11 -7
  209. data/ext/third_party/asio/asio/include/asio/basic_seq_packet_socket.hpp +9 -4
  210. data/ext/third_party/asio/asio/include/asio/basic_serial_port.hpp +6 -6
  211. data/ext/third_party/asio/asio/include/asio/basic_signal_set.hpp +4 -4
  212. data/ext/third_party/asio/asio/include/asio/basic_socket.hpp +5 -5
  213. data/ext/third_party/asio/asio/include/asio/basic_socket_acceptor.hpp +13 -7
  214. data/ext/third_party/asio/asio/include/asio/basic_stream_socket.hpp +7 -3
  215. data/ext/third_party/asio/asio/include/asio/basic_waitable_timer.hpp +52 -4
  216. data/ext/third_party/asio/asio/include/asio/bind_executor.hpp +10 -15
  217. data/ext/third_party/asio/asio/include/asio/buffer.hpp +6 -4
  218. data/ext/third_party/asio/asio/include/asio/co_spawn.hpp +380 -9
  219. data/ext/third_party/asio/asio/include/asio/defer.hpp +4 -1
  220. data/ext/third_party/asio/asio/include/asio/detached.hpp +50 -0
  221. data/ext/third_party/asio/asio/include/asio/detail/atomic_count.hpp +19 -0
  222. data/ext/third_party/asio/asio/include/asio/detail/bind_handler.hpp +144 -26
  223. data/ext/third_party/asio/asio/include/asio/detail/blocking_executor_op.hpp +107 -0
  224. data/ext/third_party/asio/asio/include/asio/detail/buffer_sequence_adapter.hpp +106 -0
  225. data/ext/third_party/asio/asio/include/asio/detail/bulk_executor_op.hpp +88 -0
  226. data/ext/third_party/asio/asio/include/asio/detail/completion_handler.hpp +10 -5
  227. data/ext/third_party/asio/asio/include/asio/detail/conditionally_enabled_event.hpp +8 -0
  228. data/ext/third_party/asio/asio/include/asio/detail/config.hpp +360 -37
  229. data/ext/third_party/asio/asio/include/asio/detail/deadline_timer_service.hpp +17 -2
  230. data/ext/third_party/asio/asio/include/asio/detail/descriptor_ops.hpp +24 -6
  231. data/ext/third_party/asio/asio/include/asio/detail/descriptor_read_op.hpp +32 -14
  232. data/ext/third_party/asio/asio/include/asio/detail/descriptor_write_op.hpp +32 -14
  233. data/ext/third_party/asio/asio/include/asio/detail/executor_function.hpp +133 -34
  234. data/ext/third_party/asio/asio/include/asio/detail/handler_alloc_helpers.hpp +42 -0
  235. data/ext/third_party/asio/asio/include/asio/detail/handler_invoke_helpers.hpp +23 -0
  236. data/ext/third_party/asio/asio/include/asio/detail/handler_tracking.hpp +26 -0
  237. data/ext/third_party/asio/asio/include/asio/detail/handler_work.hpp +370 -45
  238. data/ext/third_party/asio/asio/include/asio/detail/impl/descriptor_ops.ipp +208 -74
  239. data/ext/third_party/asio/asio/include/asio/detail/impl/handler_tracking.ipp +39 -1
  240. data/ext/third_party/asio/asio/include/asio/detail/impl/reactive_serial_port_service.ipp +12 -15
  241. data/ext/third_party/asio/asio/include/asio/detail/impl/scheduler.ipp +37 -0
  242. data/ext/third_party/asio/asio/include/asio/detail/impl/signal_set_service.ipp +2 -1
  243. data/ext/third_party/asio/asio/include/asio/detail/impl/socket_ops.ipp +661 -274
  244. data/ext/third_party/asio/asio/include/asio/detail/impl/strand_executor_service.hpp +210 -4
  245. data/ext/third_party/asio/asio/include/asio/detail/impl/strand_service.hpp +8 -9
  246. data/ext/third_party/asio/asio/include/asio/detail/impl/strand_service.ipp +5 -4
  247. data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_io_context.ipp +15 -6
  248. data/ext/third_party/asio/asio/include/asio/detail/io_object_impl.hpp +32 -50
  249. data/ext/third_party/asio/asio/include/asio/detail/memory.hpp +3 -0
  250. data/ext/third_party/asio/asio/include/asio/detail/null_event.hpp +6 -0
  251. data/ext/third_party/asio/asio/include/asio/detail/pop_options.hpp +1 -1
  252. data/ext/third_party/asio/asio/include/asio/detail/posix_event.hpp +13 -0
  253. data/ext/third_party/asio/asio/include/asio/detail/push_options.hpp +1 -1
  254. data/ext/third_party/asio/asio/include/asio/detail/reactive_descriptor_service.hpp +38 -13
  255. data/ext/third_party/asio/asio/include/asio/detail/reactive_null_buffers_op.hpp +12 -6
  256. data/ext/third_party/asio/asio/include/asio/detail/reactive_serial_port_service.hpp +2 -3
  257. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_accept_op.hpp +36 -24
  258. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_connect_op.hpp +17 -10
  259. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recv_op.hpp +38 -16
  260. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp +36 -14
  261. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp +21 -11
  262. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_send_op.hpp +43 -17
  263. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_sendto_op.hpp +39 -17
  264. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_service.hpp +44 -21
  265. data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_service_base.hpp +41 -18
  266. data/ext/third_party/asio/asio/include/asio/detail/reactive_wait_op.hpp +12 -6
  267. data/ext/third_party/asio/asio/include/asio/detail/reactor_op.hpp +3 -1
  268. data/ext/third_party/asio/asio/include/asio/detail/resolve_endpoint_op.hpp +10 -8
  269. data/ext/third_party/asio/asio/include/asio/detail/resolve_query_op.hpp +11 -9
  270. data/ext/third_party/asio/asio/include/asio/detail/scheduler.hpp +8 -0
  271. data/ext/third_party/asio/asio/include/asio/detail/signal_handler.hpp +7 -5
  272. data/ext/third_party/asio/asio/include/asio/detail/socket_ops.hpp +46 -0
  273. data/ext/third_party/asio/asio/include/asio/detail/source_location.hpp +45 -0
  274. data/ext/third_party/asio/asio/include/asio/detail/std_event.hpp +12 -0
  275. data/ext/third_party/asio/asio/include/asio/detail/strand_executor_service.hpp +25 -1
  276. data/ext/third_party/asio/asio/include/asio/detail/strand_service.hpp +4 -1
  277. data/ext/third_party/asio/asio/include/asio/detail/thread_info_base.hpp +58 -0
  278. data/ext/third_party/asio/asio/include/asio/detail/type_traits.hpp +59 -0
  279. data/ext/third_party/asio/asio/include/asio/detail/variadic_templates.hpp +144 -1
  280. data/ext/third_party/asio/asio/include/asio/detail/wait_handler.hpp +9 -6
  281. data/ext/third_party/asio/asio/include/asio/detail/win_event.hpp +13 -0
  282. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_handle_read_op.hpp +9 -5
  283. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_handle_write_op.hpp +9 -5
  284. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_io_context.hpp +5 -1
  285. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_null_buffers_op.hpp +10 -6
  286. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_overlapped_op.hpp +9 -5
  287. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_overlapped_ptr.hpp +18 -6
  288. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_accept_op.hpp +15 -11
  289. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_connect_op.hpp +10 -5
  290. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recv_op.hpp +8 -4
  291. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recvfrom_op.hpp +8 -4
  292. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recvmsg_op.hpp +8 -4
  293. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_send_op.hpp +8 -4
  294. data/ext/third_party/asio/asio/include/asio/detail/win_iocp_wait_op.hpp +10 -5
  295. data/ext/third_party/asio/asio/include/asio/detail/winrt_resolve_op.hpp +8 -4
  296. data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_connect_op.hpp +8 -4
  297. data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_recv_op.hpp +8 -4
  298. data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_send_op.hpp +8 -4
  299. data/ext/third_party/asio/asio/include/asio/detail/work_dispatcher.hpp +81 -6
  300. data/ext/third_party/asio/asio/include/asio/detail/wrapped_handler.hpp +45 -9
  301. data/ext/third_party/asio/asio/include/asio/dispatch.hpp +4 -1
  302. data/ext/third_party/asio/asio/include/asio/execution.hpp +48 -0
  303. data/ext/third_party/asio/asio/include/asio/execution/allocator.hpp +249 -0
  304. data/ext/third_party/asio/asio/include/asio/execution/any_executor.hpp +2264 -0
  305. data/ext/third_party/asio/asio/include/asio/execution/bad_executor.hpp +47 -0
  306. data/ext/third_party/asio/asio/include/asio/execution/blocking.hpp +1351 -0
  307. data/ext/third_party/asio/asio/include/asio/execution/blocking_adaptation.hpp +1064 -0
  308. data/ext/third_party/asio/asio/include/asio/execution/bulk_execute.hpp +390 -0
  309. data/ext/third_party/asio/asio/include/asio/execution/bulk_guarantee.hpp +1018 -0
  310. data/ext/third_party/asio/asio/include/asio/execution/connect.hpp +486 -0
  311. data/ext/third_party/asio/asio/include/asio/execution/context.hpp +185 -0
  312. data/ext/third_party/asio/asio/include/asio/execution/context_as.hpp +201 -0
  313. data/ext/third_party/asio/asio/include/asio/execution/detail/as_invocable.hpp +152 -0
  314. data/ext/third_party/asio/asio/include/asio/execution/detail/as_operation.hpp +105 -0
  315. data/ext/third_party/asio/asio/include/asio/execution/detail/as_receiver.hpp +128 -0
  316. data/ext/third_party/asio/asio/include/asio/execution/detail/bulk_sender.hpp +261 -0
  317. data/ext/third_party/asio/asio/include/asio/execution/detail/submit_receiver.hpp +233 -0
  318. data/ext/third_party/asio/asio/include/asio/execution/detail/void_receiver.hpp +90 -0
  319. data/ext/third_party/asio/asio/include/asio/execution/execute.hpp +264 -0
  320. data/ext/third_party/asio/asio/include/asio/execution/executor.hpp +238 -0
  321. data/ext/third_party/asio/asio/include/asio/execution/impl/bad_executor.ipp +40 -0
  322. data/ext/third_party/asio/asio/include/asio/execution/impl/receiver_invocation_error.ipp +36 -0
  323. data/ext/third_party/asio/asio/include/asio/execution/invocable_archetype.hpp +71 -0
  324. data/ext/third_party/asio/asio/include/asio/execution/mapping.hpp +917 -0
  325. data/ext/third_party/asio/asio/include/asio/execution/occupancy.hpp +178 -0
  326. data/ext/third_party/asio/asio/include/asio/execution/operation_state.hpp +94 -0
  327. data/ext/third_party/asio/asio/include/asio/execution/outstanding_work.hpp +721 -0
  328. data/ext/third_party/asio/asio/include/asio/execution/prefer_only.hpp +327 -0
  329. data/ext/third_party/asio/asio/include/asio/execution/receiver.hpp +280 -0
  330. data/ext/third_party/asio/asio/include/asio/execution/receiver_invocation_error.hpp +48 -0
  331. data/ext/third_party/asio/asio/include/asio/execution/relationship.hpp +720 -0
  332. data/ext/third_party/asio/asio/include/asio/execution/schedule.hpp +290 -0
  333. data/ext/third_party/asio/asio/include/asio/execution/scheduler.hpp +86 -0
  334. data/ext/third_party/asio/asio/include/asio/execution/sender.hpp +311 -0
  335. data/ext/third_party/asio/asio/include/asio/execution/set_done.hpp +253 -0
  336. data/ext/third_party/asio/asio/include/asio/execution/set_error.hpp +253 -0
  337. data/ext/third_party/asio/asio/include/asio/execution/set_value.hpp +486 -0
  338. data/ext/third_party/asio/asio/include/asio/execution/start.hpp +250 -0
  339. data/ext/third_party/asio/asio/include/asio/execution/submit.hpp +450 -0
  340. data/ext/third_party/asio/asio/include/asio/executor.hpp +7 -1
  341. data/ext/third_party/asio/asio/include/asio/executor_work_guard.hpp +126 -9
  342. data/ext/third_party/asio/asio/include/asio/handler_alloc_hook.hpp +28 -5
  343. data/ext/third_party/asio/asio/include/asio/handler_invoke_hook.hpp +29 -3
  344. data/ext/third_party/asio/asio/include/asio/impl/awaitable.hpp +14 -0
  345. data/ext/third_party/asio/asio/include/asio/impl/buffered_read_stream.hpp +44 -8
  346. data/ext/third_party/asio/asio/include/asio/impl/buffered_write_stream.hpp +44 -8
  347. data/ext/third_party/asio/asio/include/asio/impl/co_spawn.hpp +145 -7
  348. data/ext/third_party/asio/asio/include/asio/impl/compose.hpp +124 -22
  349. data/ext/third_party/asio/asio/include/asio/impl/connect.hpp +52 -8
  350. data/ext/third_party/asio/asio/include/asio/impl/defer.hpp +147 -12
  351. data/ext/third_party/asio/asio/include/asio/impl/dispatch.hpp +142 -12
  352. data/ext/third_party/asio/asio/include/asio/impl/executor.hpp +15 -101
  353. data/ext/third_party/asio/asio/include/asio/impl/executor.ipp +5 -0
  354. data/ext/third_party/asio/asio/include/asio/impl/handler_alloc_hook.ipp +13 -4
  355. data/ext/third_party/asio/asio/include/asio/impl/io_context.hpp +144 -57
  356. data/ext/third_party/asio/asio/include/asio/impl/multiple_exceptions.ipp +49 -0
  357. data/ext/third_party/asio/asio/include/asio/impl/post.hpp +147 -12
  358. data/ext/third_party/asio/asio/include/asio/impl/read.hpp +85 -18
  359. data/ext/third_party/asio/asio/include/asio/impl/read_at.hpp +59 -14
  360. data/ext/third_party/asio/asio/include/asio/impl/read_until.hpp +241 -56
  361. data/ext/third_party/asio/asio/include/asio/impl/redirect_error.hpp +22 -4
  362. data/ext/third_party/asio/asio/include/asio/impl/spawn.hpp +58 -22
  363. data/ext/third_party/asio/asio/include/asio/impl/src.hpp +3 -0
  364. data/ext/third_party/asio/asio/include/asio/impl/system_context.ipp +16 -4
  365. data/ext/third_party/asio/asio/include/asio/impl/system_executor.hpp +113 -12
  366. data/ext/third_party/asio/asio/include/asio/impl/thread_pool.hpp +260 -37
  367. data/ext/third_party/asio/asio/include/asio/impl/thread_pool.ipp +61 -7
  368. data/ext/third_party/asio/asio/include/asio/impl/use_awaitable.hpp +5 -2
  369. data/ext/third_party/asio/asio/include/asio/impl/use_future.hpp +147 -6
  370. data/ext/third_party/asio/asio/include/asio/impl/write.hpp +75 -14
  371. data/ext/third_party/asio/asio/include/asio/impl/write_at.hpp +53 -11
  372. data/ext/third_party/asio/asio/include/asio/io_context.hpp +706 -48
  373. data/ext/third_party/asio/asio/include/asio/io_context_strand.hpp +3 -1
  374. data/ext/third_party/asio/asio/include/asio/ip/basic_resolver.hpp +4 -4
  375. data/ext/third_party/asio/asio/include/asio/is_applicable_property.hpp +61 -0
  376. data/ext/third_party/asio/asio/include/asio/multiple_exceptions.hpp +58 -0
  377. data/ext/third_party/asio/asio/include/asio/posix/basic_descriptor.hpp +4 -4
  378. data/ext/third_party/asio/asio/include/asio/posix/basic_stream_descriptor.hpp +5 -5
  379. data/ext/third_party/asio/asio/include/asio/post.hpp +4 -1
  380. data/ext/third_party/asio/asio/include/asio/prefer.hpp +656 -0
  381. data/ext/third_party/asio/asio/include/asio/query.hpp +296 -0
  382. data/ext/third_party/asio/asio/include/asio/read_until.hpp +6 -6
  383. data/ext/third_party/asio/asio/include/asio/require.hpp +524 -0
  384. data/ext/third_party/asio/asio/include/asio/require_concept.hpp +310 -0
  385. data/ext/third_party/asio/asio/include/asio/spawn.hpp +12 -4
  386. data/ext/third_party/asio/asio/include/asio/ssl/detail/buffered_handshake_op.hpp +5 -0
  387. data/ext/third_party/asio/asio/include/asio/ssl/detail/engine.hpp +5 -0
  388. data/ext/third_party/asio/asio/include/asio/ssl/detail/handshake_op.hpp +5 -0
  389. data/ext/third_party/asio/asio/include/asio/ssl/detail/impl/engine.ipp +16 -3
  390. data/ext/third_party/asio/asio/include/asio/ssl/detail/io.hpp +38 -4
  391. data/ext/third_party/asio/asio/include/asio/ssl/detail/read_op.hpp +5 -0
  392. data/ext/third_party/asio/asio/include/asio/ssl/detail/shutdown_op.hpp +5 -0
  393. data/ext/third_party/asio/asio/include/asio/ssl/detail/stream_core.hpp +36 -2
  394. data/ext/third_party/asio/asio/include/asio/ssl/detail/write_op.hpp +10 -1
  395. data/ext/third_party/asio/asio/include/asio/ssl/stream.hpp +15 -0
  396. data/ext/third_party/asio/asio/include/asio/static_thread_pool.hpp +31 -0
  397. data/ext/third_party/asio/asio/include/asio/strand.hpp +232 -9
  398. data/ext/third_party/asio/asio/include/asio/system_context.hpp +12 -3
  399. data/ext/third_party/asio/asio/include/asio/system_executor.hpp +557 -24
  400. data/ext/third_party/asio/asio/include/asio/thread_pool.hpp +913 -37
  401. data/ext/third_party/asio/asio/include/asio/traits/bulk_execute_free.hpp +114 -0
  402. data/ext/third_party/asio/asio/include/asio/traits/bulk_execute_member.hpp +114 -0
  403. data/ext/third_party/asio/asio/include/asio/traits/connect_free.hpp +112 -0
  404. data/ext/third_party/asio/asio/include/asio/traits/connect_member.hpp +112 -0
  405. data/ext/third_party/asio/asio/include/asio/traits/equality_comparable.hpp +100 -0
  406. data/ext/third_party/asio/asio/include/asio/traits/execute_free.hpp +108 -0
  407. data/ext/third_party/asio/asio/include/asio/traits/execute_member.hpp +108 -0
  408. data/ext/third_party/asio/asio/include/asio/traits/prefer_free.hpp +108 -0
  409. data/ext/third_party/asio/asio/include/asio/traits/prefer_member.hpp +108 -0
  410. data/ext/third_party/asio/asio/include/asio/traits/query_free.hpp +108 -0
  411. data/ext/third_party/asio/asio/include/asio/traits/query_member.hpp +108 -0
  412. data/ext/third_party/asio/asio/include/asio/traits/query_static_constexpr_member.hpp +108 -0
  413. data/ext/third_party/asio/asio/include/asio/traits/require_concept_free.hpp +108 -0
  414. data/ext/third_party/asio/asio/include/asio/traits/require_concept_member.hpp +108 -0
  415. data/ext/third_party/asio/asio/include/asio/traits/require_free.hpp +108 -0
  416. data/ext/third_party/asio/asio/include/asio/traits/require_member.hpp +108 -0
  417. data/ext/third_party/asio/asio/include/asio/traits/schedule_free.hpp +108 -0
  418. data/ext/third_party/asio/asio/include/asio/traits/schedule_member.hpp +108 -0
  419. data/ext/third_party/asio/asio/include/asio/traits/set_done_free.hpp +108 -0
  420. data/ext/third_party/asio/asio/include/asio/traits/set_done_member.hpp +108 -0
  421. data/ext/third_party/asio/asio/include/asio/traits/set_error_free.hpp +112 -0
  422. data/ext/third_party/asio/asio/include/asio/traits/set_error_member.hpp +112 -0
  423. data/ext/third_party/asio/asio/include/asio/traits/set_value_free.hpp +234 -0
  424. data/ext/third_party/asio/asio/include/asio/traits/set_value_member.hpp +234 -0
  425. data/ext/third_party/asio/asio/include/asio/traits/start_free.hpp +108 -0
  426. data/ext/third_party/asio/asio/include/asio/traits/start_member.hpp +108 -0
  427. data/ext/third_party/asio/asio/include/asio/traits/static_query.hpp +108 -0
  428. data/ext/third_party/asio/asio/include/asio/traits/static_require.hpp +123 -0
  429. data/ext/third_party/asio/asio/include/asio/traits/static_require_concept.hpp +123 -0
  430. data/ext/third_party/asio/asio/include/asio/traits/submit_free.hpp +112 -0
  431. data/ext/third_party/asio/asio/include/asio/traits/submit_member.hpp +112 -0
  432. data/ext/third_party/asio/asio/include/asio/ts/executor.hpp +1 -0
  433. data/ext/third_party/asio/asio/include/asio/ts/netfwd.hpp +67 -8
  434. data/ext/third_party/asio/asio/include/asio/use_awaitable.hpp +63 -4
  435. data/ext/third_party/asio/asio/include/asio/version.hpp +1 -1
  436. data/ext/third_party/asio/asio/include/asio/windows/basic_object_handle.hpp +4 -4
  437. data/ext/third_party/asio/asio/include/asio/windows/basic_overlapped_handle.hpp +2 -2
  438. data/ext/third_party/asio/asio/include/asio/windows/basic_random_access_handle.hpp +5 -5
  439. data/ext/third_party/asio/asio/include/asio/windows/basic_stream_handle.hpp +5 -5
  440. data/ext/third_party/asio/asio/include/asio/windows/overlapped_ptr.hpp +4 -2
  441. data/ext/third_party/gsl/CMakeLists.txt +13 -5
  442. data/ext/third_party/gsl/include/gsl/gsl_assert +1 -1
  443. data/ext/third_party/gsl/include/gsl/gsl_byte +3 -3
  444. data/ext/third_party/gsl/include/gsl/gsl_narrow +52 -0
  445. data/ext/third_party/gsl/include/gsl/gsl_util +8 -50
  446. data/ext/third_party/gsl/include/gsl/multi_span +0 -10
  447. data/ext/third_party/gsl/include/gsl/pointers +14 -28
  448. data/ext/third_party/gsl/include/gsl/span +98 -46
  449. data/ext/third_party/gsl/include/gsl/string_span +37 -47
  450. data/ext/third_party/http_parser/http_parser.c +17 -10
  451. data/ext/third_party/http_parser/http_parser.h +4 -2
  452. data/ext/third_party/json/include/tao/json/basic_value.hpp +3 -2
  453. data/ext/third_party/json/include/tao/json/binary.hpp +4 -4
  454. data/ext/third_party/json/include/tao/json/binary_view.hpp +2 -2
  455. data/ext/third_party/json/include/tao/json/binding.hpp +2 -2
  456. data/ext/third_party/json/include/tao/json/binding/factory.hpp +8 -7
  457. data/ext/third_party/json/include/tao/json/binding/internal/array.hpp +2 -1
  458. data/ext/third_party/json/include/tao/json/binding/internal/object.hpp +6 -5
  459. data/ext/third_party/json/include/tao/json/binding/versions.hpp +3 -1
  460. data/ext/third_party/json/include/tao/json/cbor.hpp +1 -0
  461. data/ext/third_party/json/include/tao/json/cbor/consume_file.hpp +7 -7
  462. data/ext/third_party/json/include/tao/json/cbor/events/from_binary.hpp +43 -0
  463. data/ext/third_party/json/include/tao/json/cbor/events/from_file.hpp +4 -4
  464. data/ext/third_party/json/include/tao/json/cbor/events/from_string.hpp +3 -3
  465. data/ext/third_party/json/include/tao/json/cbor/from_binary.hpp +32 -0
  466. data/ext/third_party/json/include/tao/json/cbor/from_file.hpp +5 -5
  467. data/ext/third_party/json/include/tao/json/cbor/internal/grammar.hpp +2 -1
  468. data/ext/third_party/json/include/tao/json/consume_file.hpp +7 -7
  469. data/ext/third_party/json/include/tao/json/contrib/internal/indirect_traits.hpp +13 -6
  470. data/ext/third_party/json/include/tao/json/contrib/position.hpp +15 -15
  471. data/ext/third_party/json/include/tao/json/contrib/reference.hpp +5 -7
  472. data/ext/third_party/json/include/tao/json/contrib/schema.hpp +58 -35
  473. data/ext/third_party/json/include/tao/json/contrib/shared_ptr_traits.hpp +12 -4
  474. data/ext/third_party/json/include/tao/json/contrib/unique_ptr_traits.hpp +12 -4
  475. data/ext/third_party/json/include/tao/json/contrib/unordered_map_traits.hpp +1 -1
  476. data/ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp +2 -2
  477. data/ext/third_party/json/include/tao/json/events/compare.hpp +2 -12
  478. data/ext/third_party/json/include/tao/json/events/from_file.hpp +4 -4
  479. data/ext/third_party/json/include/tao/json/events/from_string.hpp +2 -2
  480. data/ext/third_party/json/include/tao/json/events/invalid_string_to_binary.hpp +1 -1
  481. data/ext/third_party/json/include/tao/json/events/key_camel_case_to_snake_case.hpp +3 -3
  482. data/ext/third_party/json/include/tao/json/events/key_snake_case_to_camel_case.hpp +1 -1
  483. data/ext/third_party/json/include/tao/json/events/tee.hpp +2 -2
  484. data/ext/third_party/json/include/tao/json/events/to_pretty_stream.hpp +1 -1
  485. data/ext/third_party/json/include/tao/json/events/to_stream.hpp +1 -1
  486. data/ext/third_party/json/include/tao/json/events/transformer.hpp +3 -3
  487. data/ext/third_party/json/include/tao/json/events/validate_event_order.hpp +3 -3
  488. data/ext/third_party/json/include/tao/json/events/virtual_ref.hpp +6 -0
  489. data/ext/third_party/json/include/tao/json/external/pegtl.hpp +4 -13
  490. data/ext/third_party/json/include/tao/json/external/pegtl/argv_input.hpp +3 -5
  491. data/ext/third_party/json/include/tao/json/external/pegtl/ascii.hpp +5 -18
  492. data/ext/third_party/json/include/tao/json/external/pegtl/buffer_input.hpp +3 -3
  493. data/ext/third_party/json/include/tao/json/external/pegtl/change_action.hpp +2 -2
  494. data/ext/third_party/json/include/tao/json/external/pegtl/change_action_and_state.hpp +6 -6
  495. data/ext/third_party/json/include/tao/json/external/pegtl/change_action_and_states.hpp +5 -5
  496. data/ext/third_party/json/include/tao/json/external/pegtl/change_control.hpp +2 -2
  497. data/ext/third_party/json/include/tao/json/external/pegtl/change_state.hpp +6 -6
  498. data/ext/third_party/json/include/tao/json/external/pegtl/change_states.hpp +5 -5
  499. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/alphabet.hpp +52 -52
  500. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/analyze.hpp +176 -0
  501. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/analyze_traits.hpp +275 -0
  502. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/control_action.hpp +77 -0
  503. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/coverage.hpp +151 -0
  504. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/forward.hpp +16 -0
  505. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/http.hpp +37 -18
  506. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/internal.hpp +20 -22
  507. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf16.hpp +6 -10
  508. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf32.hpp +6 -10
  509. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf8.hpp +2 -4
  510. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/if_then.hpp +11 -10
  511. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/integer.hpp +116 -131
  512. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/endian.hpp +4 -4
  513. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/endian_gcc.hpp +2 -2
  514. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/endian_win.hpp +2 -2
  515. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_mask_uint.hpp +9 -9
  516. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_mask_uint8.hpp +9 -10
  517. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_uint.hpp +9 -9
  518. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_uint8.hpp +9 -10
  519. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_utf16.hpp +10 -10
  520. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/peek_utf32.hpp +9 -9
  521. data/ext/third_party/json/include/tao/json/external/pegtl/{internal → contrib/internal}/read_uint.hpp +3 -3
  522. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/set_stack_guard.hpp +52 -0
  523. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/parse_tree.hpp +80 -201
  524. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/parse_tree_to_dot.hpp +11 -10
  525. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/print.hpp +75 -0
  526. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/print_coverage.hpp +53 -0
  527. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/raw_string.hpp +45 -36
  528. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/remove_first_state.hpp +33 -50
  529. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/remove_last_states.hpp +117 -0
  530. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/rep_one_min_max.hpp +43 -11
  531. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/rep_string.hpp +1 -2
  532. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/shuffle_states.hpp +193 -0
  533. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/state_control.hpp +118 -0
  534. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/trace.hpp +227 -0
  535. data/ext/third_party/json/include/tao/json/external/pegtl/{uint16.hpp → contrib/uint16.hpp} +5 -5
  536. data/ext/third_party/json/include/tao/json/external/pegtl/{uint32.hpp → contrib/uint32.hpp} +5 -5
  537. data/ext/third_party/json/include/tao/json/external/pegtl/{uint64.hpp → contrib/uint64.hpp} +5 -5
  538. data/ext/third_party/json/include/tao/json/external/pegtl/{uint8.hpp → contrib/uint8.hpp} +5 -5
  539. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/unescape.hpp +14 -14
  540. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uri.hpp +1 -1
  541. data/ext/third_party/json/include/tao/json/external/pegtl/{utf16.hpp → contrib/utf16.hpp} +5 -5
  542. data/ext/third_party/json/include/tao/json/external/pegtl/{utf32.hpp → contrib/utf32.hpp} +5 -5
  543. data/ext/third_party/json/include/tao/json/external/pegtl/cstream_input.hpp +2 -3
  544. data/ext/third_party/json/include/tao/json/external/pegtl/{internal/demangle.hpp → demangle.hpp} +12 -14
  545. data/ext/third_party/json/include/tao/json/external/pegtl/disable_action.hpp +2 -2
  546. data/ext/third_party/json/include/tao/json/external/pegtl/discard_input.hpp +2 -2
  547. data/ext/third_party/json/include/tao/json/external/pegtl/discard_input_on_failure.hpp +2 -2
  548. data/ext/third_party/json/include/tao/json/external/pegtl/discard_input_on_success.hpp +2 -2
  549. data/ext/third_party/json/include/tao/json/external/pegtl/enable_action.hpp +2 -2
  550. data/ext/third_party/json/include/tao/json/external/pegtl/file_input.hpp +1 -1
  551. data/ext/third_party/json/include/tao/json/external/pegtl/internal/action.hpp +19 -9
  552. data/ext/third_party/json/include/tao/json/external/pegtl/internal/action_input.hpp +7 -8
  553. data/ext/third_party/json/include/tao/json/external/pegtl/internal/any.hpp +14 -14
  554. data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply.hpp +9 -9
  555. data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply0.hpp +8 -7
  556. data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply_single.hpp +4 -4
  557. data/ext/third_party/json/include/tao/json/external/pegtl/internal/at.hpp +17 -15
  558. data/ext/third_party/json/include/tao/json/external/pegtl/internal/bof.hpp +7 -6
  559. data/ext/third_party/json/include/tao/json/external/pegtl/internal/bol.hpp +8 -8
  560. data/ext/third_party/json/include/tao/json/external/pegtl/internal/bump.hpp +4 -4
  561. data/ext/third_party/json/include/tao/json/external/pegtl/internal/bump_help.hpp +3 -3
  562. data/ext/third_party/json/include/tao/json/external/pegtl/internal/bytes.hpp +17 -10
  563. data/ext/third_party/json/include/tao/json/external/pegtl/internal/control.hpp +19 -9
  564. data/ext/third_party/json/include/tao/json/external/pegtl/internal/cr_crlf_eol.hpp +2 -2
  565. data/ext/third_party/json/include/tao/json/external/pegtl/internal/cr_eol.hpp +2 -2
  566. data/ext/third_party/json/include/tao/json/external/pegtl/internal/crlf_eol.hpp +2 -2
  567. data/ext/third_party/json/include/tao/json/external/pegtl/internal/cstream_reader.hpp +1 -1
  568. data/ext/third_party/json/include/tao/json/external/pegtl/internal/{always_false.hpp → dependent_false.hpp} +3 -8
  569. data/ext/third_party/json/include/tao/json/external/pegtl/internal/disable.hpp +19 -9
  570. data/ext/third_party/json/include/tao/json/external/pegtl/internal/discard.hpp +7 -6
  571. data/ext/third_party/json/include/tao/json/external/pegtl/internal/enable.hpp +19 -9
  572. data/ext/third_party/json/include/tao/json/external/pegtl/internal/{skip_control.hpp → enable_control.hpp} +5 -5
  573. data/ext/third_party/json/include/tao/json/external/pegtl/internal/eof.hpp +7 -6
  574. data/ext/third_party/json/include/tao/json/external/pegtl/internal/eol.hpp +8 -7
  575. data/ext/third_party/json/include/tao/json/external/pegtl/internal/eolf.hpp +8 -7
  576. data/ext/third_party/json/include/tao/json/external/pegtl/internal/failure.hpp +32 -0
  577. data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_mapper_posix.hpp +61 -10
  578. data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_mapper_win32.hpp +27 -33
  579. data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_reader.hpp +27 -28
  580. data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_apply.hpp +3 -7
  581. data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_apply0.hpp +3 -7
  582. data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_match.hpp +4 -20
  583. data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_unwind.hpp +21 -0
  584. data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_apply.hpp +8 -7
  585. data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_must.hpp +8 -9
  586. data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_must_else.hpp +2 -0
  587. data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_then_else.hpp +7 -7
  588. data/ext/third_party/json/include/tao/json/external/pegtl/internal/istream_reader.hpp +1 -2
  589. data/ext/third_party/json/include/tao/json/external/pegtl/internal/istring.hpp +11 -11
  590. data/ext/third_party/json/include/tao/json/external/pegtl/internal/iterator.hpp +7 -10
  591. data/ext/third_party/json/include/tao/json/external/pegtl/internal/lf_crlf_eol.hpp +2 -2
  592. data/ext/third_party/json/include/tao/json/external/pegtl/internal/lf_eol.hpp +2 -2
  593. data/ext/third_party/json/include/tao/json/external/pegtl/internal/list_tail.hpp +4 -2
  594. data/ext/third_party/json/include/tao/json/external/pegtl/internal/list_tail_pad.hpp +1 -1
  595. data/ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp +3 -5
  596. data/ext/third_party/json/include/tao/json/external/pegtl/internal/minus.hpp +21 -0
  597. data/ext/third_party/json/include/tao/json/external/pegtl/internal/missing_apply.hpp +5 -2
  598. data/ext/third_party/json/include/tao/json/external/pegtl/internal/missing_apply0.hpp +5 -2
  599. data/ext/third_party/json/include/tao/json/external/pegtl/internal/must.hpp +16 -24
  600. data/ext/third_party/json/include/tao/json/external/pegtl/internal/not_at.hpp +17 -15
  601. data/ext/third_party/json/include/tao/json/external/pegtl/internal/one.hpp +23 -12
  602. data/ext/third_party/json/include/tao/json/external/pegtl/internal/opt.hpp +16 -16
  603. data/ext/third_party/json/include/tao/json/external/pegtl/internal/path_to_string.hpp +26 -0
  604. data/ext/third_party/json/include/tao/json/external/pegtl/internal/peek_char.hpp +5 -5
  605. data/ext/third_party/json/include/tao/json/external/pegtl/internal/peek_utf8.hpp +12 -13
  606. data/ext/third_party/json/include/tao/json/external/pegtl/internal/plus.hpp +18 -11
  607. data/ext/third_party/json/include/tao/json/external/pegtl/internal/raise.hpp +8 -17
  608. data/ext/third_party/json/include/tao/json/external/pegtl/internal/range.hpp +22 -17
  609. data/ext/third_party/json/include/tao/json/external/pegtl/internal/ranges.hpp +28 -18
  610. data/ext/third_party/json/include/tao/json/external/pegtl/internal/rematch.hpp +12 -9
  611. data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep.hpp +26 -25
  612. data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep_min_max.hpp +23 -21
  613. data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep_opt.hpp +24 -9
  614. data/ext/third_party/json/include/tao/json/external/pegtl/internal/require.hpp +10 -10
  615. data/ext/third_party/json/include/tao/json/external/pegtl/internal/rules.hpp +4 -4
  616. data/ext/third_party/json/include/tao/json/external/pegtl/internal/seq.hpp +18 -33
  617. data/ext/third_party/json/include/tao/json/external/pegtl/internal/sor.hpp +24 -17
  618. data/ext/third_party/json/include/tao/json/external/pegtl/internal/star.hpp +13 -8
  619. data/ext/third_party/json/include/tao/json/external/pegtl/internal/state.hpp +21 -11
  620. data/ext/third_party/json/include/tao/json/external/pegtl/internal/string.hpp +11 -11
  621. data/ext/third_party/json/include/tao/json/external/pegtl/internal/success.hpp +32 -0
  622. data/ext/third_party/json/include/tao/json/external/pegtl/internal/try_catch_type.hpp +16 -16
  623. data/ext/third_party/json/include/tao/json/external/pegtl/internal/until.hpp +18 -14
  624. data/ext/third_party/json/include/tao/json/external/pegtl/istream_input.hpp +2 -3
  625. data/ext/third_party/json/include/tao/json/external/pegtl/match.hpp +125 -29
  626. data/ext/third_party/json/include/tao/json/external/pegtl/memory_input.hpp +32 -48
  627. data/ext/third_party/json/include/tao/json/external/pegtl/mmap_input.hpp +16 -16
  628. data/ext/third_party/json/include/tao/json/external/pegtl/must_if.hpp +64 -0
  629. data/ext/third_party/json/include/tao/json/external/pegtl/normal.hpp +25 -25
  630. data/ext/third_party/json/include/tao/json/external/pegtl/nothing.hpp +1 -2
  631. data/ext/third_party/json/include/tao/json/external/pegtl/parse.hpp +6 -8
  632. data/ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp +80 -35
  633. data/ext/third_party/json/include/tao/json/external/pegtl/position.hpp +18 -10
  634. data/ext/third_party/json/include/tao/json/external/pegtl/read_input.hpp +18 -38
  635. data/ext/third_party/json/include/tao/json/external/pegtl/rules.hpp +6 -5
  636. data/ext/third_party/json/include/tao/json/external/pegtl/string_input.hpp +3 -5
  637. data/ext/third_party/json/include/tao/json/external/pegtl/type_list.hpp +46 -0
  638. data/ext/third_party/json/include/tao/json/external/pegtl/visit.hpp +66 -0
  639. data/ext/third_party/json/include/tao/json/from_file.hpp +5 -5
  640. data/ext/third_party/json/include/tao/json/internal/action.hpp +3 -3
  641. data/ext/third_party/json/include/tao/json/internal/dependent_false.hpp +14 -0
  642. data/ext/third_party/json/include/tao/json/internal/errors.hpp +17 -17
  643. data/ext/third_party/json/include/tao/json/internal/format.hpp +0 -2
  644. data/ext/third_party/json/include/tao/json/internal/grammar.hpp +17 -17
  645. data/ext/third_party/json/include/tao/json/internal/pair.hpp +1 -1
  646. data/ext/third_party/json/include/tao/json/internal/sha256.hpp +8 -8
  647. data/ext/third_party/json/include/tao/json/internal/single.hpp +1 -1
  648. data/ext/third_party/json/include/tao/json/internal/type_traits.hpp +12 -29
  649. data/ext/third_party/json/include/tao/json/jaxn/consume_file.hpp +7 -7
  650. data/ext/third_party/json/include/tao/json/jaxn/events/from_file.hpp +4 -4
  651. data/ext/third_party/json/include/tao/json/jaxn/events/from_string.hpp +2 -2
  652. data/ext/third_party/json/include/tao/json/jaxn/from_file.hpp +5 -5
  653. data/ext/third_party/json/include/tao/json/jaxn/internal/action.hpp +6 -6
  654. data/ext/third_party/json/include/tao/json/jaxn/internal/bunescape_action.hpp +2 -2
  655. data/ext/third_party/json/include/tao/json/jaxn/internal/errors.hpp +43 -43
  656. data/ext/third_party/json/include/tao/json/jaxn/internal/grammar.hpp +36 -36
  657. data/ext/third_party/json/include/tao/json/jaxn/internal/integer.hpp +10 -11
  658. data/ext/third_party/json/include/tao/json/jaxn/is_identifier.hpp +2 -2
  659. data/ext/third_party/json/include/tao/json/jaxn/parts_parser.hpp +1 -3
  660. data/ext/third_party/json/include/tao/json/message_extension.hpp +2 -2
  661. data/ext/third_party/json/include/tao/json/msgpack.hpp +1 -0
  662. data/ext/third_party/json/include/tao/json/msgpack/consume_file.hpp +7 -7
  663. data/ext/third_party/json/include/tao/json/msgpack/events/from_binary.hpp +43 -0
  664. data/ext/third_party/json/include/tao/json/msgpack/events/from_file.hpp +4 -4
  665. data/ext/third_party/json/include/tao/json/msgpack/events/from_string.hpp +4 -4
  666. data/ext/third_party/json/include/tao/json/msgpack/events/to_stream.hpp +4 -4
  667. data/ext/third_party/json/include/tao/json/msgpack/from_binary.hpp +32 -0
  668. data/ext/third_party/json/include/tao/json/msgpack/from_file.hpp +5 -5
  669. data/ext/third_party/json/include/tao/json/msgpack/internal/grammar.hpp +2 -1
  670. data/ext/third_party/json/include/tao/json/operators.hpp +0 -4
  671. data/ext/third_party/json/include/tao/json/parts_parser.hpp +3 -7
  672. data/ext/third_party/json/include/tao/json/self_contained.hpp +6 -18
  673. data/ext/third_party/json/include/tao/json/span.hpp +94 -166
  674. data/ext/third_party/json/include/tao/json/ubjson.hpp +1 -0
  675. data/ext/third_party/json/include/tao/json/ubjson/consume_file.hpp +7 -7
  676. data/ext/third_party/json/include/tao/json/ubjson/events/from_binary.hpp +43 -0
  677. data/ext/third_party/json/include/tao/json/ubjson/events/from_file.hpp +4 -4
  678. data/ext/third_party/json/include/tao/json/ubjson/events/from_string.hpp +3 -3
  679. data/ext/third_party/json/include/tao/json/ubjson/from_binary.hpp +32 -0
  680. data/ext/third_party/json/include/tao/json/ubjson/from_file.hpp +5 -5
  681. data/ext/third_party/json/include/tao/json/ubjson/internal/grammar.hpp +5 -3
  682. data/ext/third_party/json/include/tao/json/utf8.hpp +1 -1
  683. data/ext/third_party/snappy/snappy.cc +6 -2
  684. data/ext/third_party/spdlog/CMakeLists.txt +24 -57
  685. data/ext/third_party/spdlog/cmake/version.rc.in +1 -1
  686. data/ext/third_party/spdlog/include/spdlog/async.h +3 -3
  687. data/ext/third_party/spdlog/include/spdlog/cfg/argv.h +3 -4
  688. data/ext/third_party/spdlog/include/spdlog/cfg/env.h +6 -4
  689. data/ext/third_party/spdlog/include/spdlog/cfg/helpers-inl.h +22 -6
  690. data/ext/third_party/spdlog/include/spdlog/cfg/helpers.h +3 -2
  691. data/ext/third_party/spdlog/include/spdlog/common.h +1 -2
  692. data/ext/third_party/spdlog/include/spdlog/details/fmt_helper.h +9 -1
  693. data/ext/third_party/spdlog/include/spdlog/details/os.h +1 -1
  694. data/ext/third_party/spdlog/include/spdlog/details/registry-inl.h +21 -7
  695. data/ext/third_party/spdlog/include/spdlog/details/registry.h +6 -3
  696. data/ext/third_party/spdlog/include/spdlog/details/synchronous_factory.h +1 -1
  697. data/ext/third_party/spdlog/include/spdlog/details/tcp_client-windows.h +1 -1
  698. data/ext/third_party/spdlog/include/spdlog/details/tcp_client.h +8 -7
  699. data/ext/third_party/spdlog/include/spdlog/fmt/bin_to_hex.h +2 -2
  700. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/chrono.h +66 -62
  701. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/color.h +35 -37
  702. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/compile.h +173 -103
  703. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/core.h +538 -445
  704. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/format-inl.h +114 -64
  705. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/format.h +1152 -1071
  706. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/locale.h +16 -16
  707. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/os.h +450 -0
  708. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/ostream.h +37 -13
  709. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/posix.h +1 -1
  710. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/printf.h +93 -63
  711. data/ext/third_party/spdlog/include/spdlog/fmt/bundled/ranges.h +35 -36
  712. data/ext/third_party/spdlog/include/spdlog/fmt/chrono.h +20 -0
  713. data/ext/third_party/spdlog/include/spdlog/fmt/fmt.h +2 -0
  714. data/ext/third_party/spdlog/include/spdlog/logger-inl.h +5 -1
  715. data/ext/third_party/spdlog/include/spdlog/logger.h +50 -76
  716. data/ext/third_party/spdlog/include/spdlog/pattern_formatter-inl.h +23 -8
  717. data/ext/third_party/spdlog/include/spdlog/pattern_formatter.h +3 -3
  718. data/ext/third_party/spdlog/include/spdlog/sinks/daily_file_sink.h +1 -1
  719. data/ext/third_party/spdlog/include/spdlog/sinks/msvc_sink.h +5 -5
  720. data/ext/third_party/spdlog/include/spdlog/sinks/ringbuffer_sink.h +6 -4
  721. data/ext/third_party/spdlog/include/spdlog/sinks/stdout_sinks-inl.h +32 -3
  722. data/ext/third_party/spdlog/include/spdlog/sinks/stdout_sinks.h +7 -0
  723. data/ext/third_party/spdlog/include/spdlog/sinks/wincolor_sink-inl.h +4 -14
  724. data/ext/third_party/spdlog/include/spdlog/spdlog-inl.h +11 -1
  725. data/ext/third_party/spdlog/include/spdlog/spdlog.h +23 -68
  726. data/ext/third_party/spdlog/include/spdlog/stopwatch.h +61 -0
  727. data/ext/third_party/spdlog/include/spdlog/version.h +2 -2
  728. data/ext/third_party/spdlog/src/fmt.cpp +21 -147
  729. data/lib/active_support/cache/couchbase_store.rb +362 -0
  730. data/lib/couchbase.rb +3 -1
  731. data/lib/couchbase/analytics_options.rb +2 -74
  732. data/lib/couchbase/authenticator.rb +41 -1
  733. data/lib/couchbase/binary_collection.rb +63 -24
  734. data/lib/couchbase/binary_collection_options.rb +1 -75
  735. data/lib/couchbase/bucket.rb +43 -38
  736. data/lib/couchbase/cluster.rb +225 -127
  737. data/lib/couchbase/collection.rb +323 -92
  738. data/lib/couchbase/collection_options.rb +73 -239
  739. data/lib/couchbase/configuration.rb +57 -0
  740. data/lib/couchbase/datastructures.rb +7 -1
  741. data/lib/couchbase/datastructures/couchbase_list.rb +22 -33
  742. data/lib/couchbase/datastructures/couchbase_map.rb +24 -35
  743. data/lib/couchbase/datastructures/couchbase_queue.rb +19 -30
  744. data/lib/couchbase/datastructures/couchbase_set.rb +14 -24
  745. data/lib/couchbase/diagnostics.rb +181 -0
  746. data/lib/couchbase/errors.rb +125 -7
  747. data/lib/couchbase/json_transcoder.rb +4 -4
  748. data/lib/couchbase/logger.rb +42 -0
  749. data/lib/couchbase/management.rb +27 -0
  750. data/lib/couchbase/management/analytics_index_manager.rb +38 -38
  751. data/lib/couchbase/management/bucket_manager.rb +71 -31
  752. data/lib/couchbase/management/collection_manager.rb +12 -5
  753. data/lib/couchbase/management/query_index_manager.rb +61 -16
  754. data/lib/couchbase/management/search_index_manager.rb +58 -14
  755. data/lib/couchbase/management/user_manager.rb +176 -50
  756. data/lib/couchbase/management/view_index_manager.rb +12 -6
  757. data/lib/couchbase/mutation_state.rb +13 -1
  758. data/lib/couchbase/options.rb +2113 -0
  759. data/lib/couchbase/query_options.rb +6 -128
  760. data/lib/couchbase/railtie.rb +45 -0
  761. data/lib/couchbase/scope.rb +88 -2
  762. data/lib/couchbase/search_options.rb +99 -111
  763. data/lib/couchbase/subdoc.rb +32 -29
  764. data/{Gemfile → lib/couchbase/utils.rb} +5 -17
  765. data/lib/couchbase/utils/time.rb +52 -0
  766. data/lib/couchbase/version.rb +22 -3
  767. data/lib/couchbase/view_options.rb +2 -93
  768. data/lib/{couchbase/common_options.rb → rails/generators/couchbase/config/config_generator.rb} +10 -12
  769. metadata +212 -269
  770. data/.yardopts +0 -1
  771. data/Rakefile +0 -51
  772. data/couchbase.gemspec +0 -78
  773. data/examples/analytics.rb +0 -221
  774. data/examples/crud.rb +0 -20
  775. data/examples/managing_analytics_indexes.rb +0 -72
  776. data/examples/managing_buckets.rb +0 -47
  777. data/examples/managing_collections.rb +0 -58
  778. data/examples/managing_query_indexes.rb +0 -63
  779. data/examples/managing_search_indexes.rb +0 -62
  780. data/examples/managing_view_indexes.rb +0 -54
  781. data/examples/query.rb +0 -18
  782. data/examples/query_with_consistency.rb +0 -76
  783. data/examples/search.rb +0 -187
  784. data/examples/search_with_consistency.rb +0 -84
  785. data/examples/subdocument.rb +0 -51
  786. data/examples/view.rb +0 -50
  787. data/ext/.clang-format +0 -15
  788. data/ext/.clang-tidy +0 -22
  789. data/ext/.cmake-format.yaml +0 -8
  790. data/ext/.gitignore +0 -2
  791. data/ext/.idea/.name +0 -1
  792. data/ext/.idea/dictionaries/couchbase_terms.xml +0 -14
  793. data/ext/.idea/ext.iml +0 -2
  794. data/ext/.idea/misc.xml +0 -16
  795. data/ext/.idea/modules.xml +0 -8
  796. data/ext/.idea/vcs.xml +0 -12
  797. data/ext/test/main.cxx +0 -136
  798. data/ext/third_party/asio/.appveyor.yml +0 -107
  799. data/ext/third_party/asio/.cirrus.yml +0 -16
  800. data/ext/third_party/asio/.gitignore +0 -3
  801. data/ext/third_party/asio/.travis.yml +0 -323
  802. data/ext/third_party/asio/asio/.gitignore +0 -23
  803. data/ext/third_party/asio/asio/COPYING +0 -4
  804. data/ext/third_party/asio/asio/INSTALL +0 -5
  805. data/ext/third_party/asio/asio/LICENSE_1_0.txt +0 -23
  806. data/ext/third_party/asio/asio/Makefile.am +0 -19
  807. data/ext/third_party/asio/asio/README +0 -4
  808. data/ext/third_party/asio/asio/asio.manifest +0 -4865
  809. data/ext/third_party/asio/asio/autogen.sh +0 -55
  810. data/ext/third_party/asio/asio/boost_asio.manifest +0 -5193
  811. data/ext/third_party/asio/asio/boostify.pl +0 -603
  812. data/ext/third_party/asio/asio/configure.ac +0 -182
  813. data/ext/third_party/asio/asio/include/.gitignore +0 -2
  814. data/ext/third_party/asio/asio/include/Makefile.am +0 -484
  815. data/ext/third_party/asio/asio/include/asio/detail/io_object_executor.hpp +0 -167
  816. data/ext/third_party/asio/asio/include/asio/impl/src.cpp +0 -25
  817. data/ext/third_party/asio/asio/release.pl +0 -440
  818. data/ext/third_party/asio/asio/src/.gitignore +0 -11
  819. data/ext/third_party/asio/asio/src/Makefile.am +0 -23
  820. data/ext/third_party/asio/asio/src/Makefile.mgw +0 -204
  821. data/ext/third_party/asio/asio/src/Makefile.msc +0 -497
  822. data/ext/third_party/asio/asio/src/asio.cpp +0 -11
  823. data/ext/third_party/asio/asio/src/asio_ssl.cpp +0 -11
  824. data/ext/third_party/asio/asio/src/doc/.gitignore +0 -5
  825. data/ext/third_party/asio/asio/src/doc/Jamfile.v2 +0 -62
  826. data/ext/third_party/asio/asio/src/doc/asio.png +0 -0
  827. data/ext/third_party/asio/asio/src/doc/asio.qbk +0 -127
  828. data/ext/third_party/asio/asio/src/doc/asioref.sty +0 -90
  829. data/ext/third_party/asio/asio/src/doc/asioref.xsl +0 -94
  830. data/ext/third_party/asio/asio/src/doc/boost_bind_dox.txt +0 -5
  831. data/ext/third_party/asio/asio/src/doc/doxy2qbk.pl +0 -22
  832. data/ext/third_party/asio/asio/src/doc/examples.qbk +0 -564
  833. data/ext/third_party/asio/asio/src/doc/history.qbk +0 -1794
  834. data/ext/third_party/asio/asio/src/doc/index.xml +0 -13
  835. data/ext/third_party/asio/asio/src/doc/makepdf.pl +0 -26
  836. data/ext/third_party/asio/asio/src/doc/net_ts.qbk +0 -479
  837. data/ext/third_party/asio/asio/src/doc/noncopyable_dox.txt +0 -3
  838. data/ext/third_party/asio/asio/src/doc/overview.qbk +0 -103
  839. data/ext/third_party/asio/asio/src/doc/overview/allocation.qbk +0 -89
  840. data/ext/third_party/asio/asio/src/doc/overview/async.qbk +0 -185
  841. data/ext/third_party/asio/asio/src/doc/overview/async_op1.dot +0 -78
  842. data/ext/third_party/asio/asio/src/doc/overview/async_op1.png +0 -0
  843. data/ext/third_party/asio/asio/src/doc/overview/async_op2.dot +0 -78
  844. data/ext/third_party/asio/asio/src/doc/overview/async_op2.png +0 -0
  845. data/ext/third_party/asio/asio/src/doc/overview/basics.qbk +0 -106
  846. data/ext/third_party/asio/asio/src/doc/overview/bsd_sockets.qbk +0 -270
  847. data/ext/third_party/asio/asio/src/doc/overview/buffers.qbk +0 -163
  848. data/ext/third_party/asio/asio/src/doc/overview/concurrency_hint.qbk +0 -88
  849. data/ext/third_party/asio/asio/src/doc/overview/coroutine.qbk +0 -51
  850. data/ext/third_party/asio/asio/src/doc/overview/coroutines_ts.qbk +0 -97
  851. data/ext/third_party/asio/asio/src/doc/overview/cpp2011.qbk +0 -271
  852. data/ext/third_party/asio/asio/src/doc/overview/handler_tracking.qbk +0 -220
  853. data/ext/third_party/asio/asio/src/doc/overview/implementation.qbk +0 -305
  854. data/ext/third_party/asio/asio/src/doc/overview/iostreams.qbk +0 -72
  855. data/ext/third_party/asio/asio/src/doc/overview/line_based.qbk +0 -118
  856. data/ext/third_party/asio/asio/src/doc/overview/other_protocols.qbk +0 -94
  857. data/ext/third_party/asio/asio/src/doc/overview/posix.qbk +0 -152
  858. data/ext/third_party/asio/asio/src/doc/overview/proactor.dot +0 -100
  859. data/ext/third_party/asio/asio/src/doc/overview/proactor.png +0 -0
  860. data/ext/third_party/asio/asio/src/doc/overview/protocols.qbk +0 -149
  861. data/ext/third_party/asio/asio/src/doc/overview/rationale.qbk +0 -54
  862. data/ext/third_party/asio/asio/src/doc/overview/reactor.qbk +0 -44
  863. data/ext/third_party/asio/asio/src/doc/overview/serial_ports.qbk +0 -45
  864. data/ext/third_party/asio/asio/src/doc/overview/signals.qbk +0 -44
  865. data/ext/third_party/asio/asio/src/doc/overview/spawn.qbk +0 -102
  866. data/ext/third_party/asio/asio/src/doc/overview/ssl.qbk +0 -124
  867. data/ext/third_party/asio/asio/src/doc/overview/strands.qbk +0 -114
  868. data/ext/third_party/asio/asio/src/doc/overview/streams.qbk +0 -62
  869. data/ext/third_party/asio/asio/src/doc/overview/sync_op.dot +0 -67
  870. data/ext/third_party/asio/asio/src/doc/overview/sync_op.png +0 -0
  871. data/ext/third_party/asio/asio/src/doc/overview/threads.qbk +0 -67
  872. data/ext/third_party/asio/asio/src/doc/overview/timers.qbk +0 -52
  873. data/ext/third_party/asio/asio/src/doc/overview/windows.qbk +0 -126
  874. data/ext/third_party/asio/asio/src/doc/project-root.jam +0 -1
  875. data/ext/third_party/asio/asio/src/doc/quickref.xml +0 -561
  876. data/ext/third_party/asio/asio/src/doc/reference.dox +0 -264
  877. data/ext/third_party/asio/asio/src/doc/reference.qbk +0 -125973
  878. data/ext/third_party/asio/asio/src/doc/reference.xsl +0 -1831
  879. data/ext/third_party/asio/asio/src/doc/release_checklist.htm +0 -68
  880. data/ext/third_party/asio/asio/src/doc/requirements/AcceptHandler.qbk +0 -72
  881. data/ext/third_party/asio/asio/src/doc/requirements/AcceptableProtocol.qbk +0 -25
  882. data/ext/third_party/asio/asio/src/doc/requirements/AsyncRandomAccessReadDevice.qbk +0 -56
  883. data/ext/third_party/asio/asio/src/doc/requirements/AsyncRandomAccessWriteDevice.qbk +0 -57
  884. data/ext/third_party/asio/asio/src/doc/requirements/AsyncReadStream.qbk +0 -50
  885. data/ext/third_party/asio/asio/src/doc/requirements/AsyncWriteStream.qbk +0 -48
  886. data/ext/third_party/asio/asio/src/doc/requirements/BufferedHandshakeHandler.qbk +0 -55
  887. data/ext/third_party/asio/asio/src/doc/requirements/CompletionCondition.qbk +0 -42
  888. data/ext/third_party/asio/asio/src/doc/requirements/CompletionHandler.qbk +0 -63
  889. data/ext/third_party/asio/asio/src/doc/requirements/ConnectCondition.qbk +0 -34
  890. data/ext/third_party/asio/asio/src/doc/requirements/ConnectHandler.qbk +0 -72
  891. data/ext/third_party/asio/asio/src/doc/requirements/ConstBufferSequence.qbk +0 -53
  892. data/ext/third_party/asio/asio/src/doc/requirements/DynamicBuffer.qbk +0 -16
  893. data/ext/third_party/asio/asio/src/doc/requirements/DynamicBuffer_v1.qbk +0 -93
  894. data/ext/third_party/asio/asio/src/doc/requirements/DynamicBuffer_v2.qbk +0 -94
  895. data/ext/third_party/asio/asio/src/doc/requirements/Endpoint.qbk +0 -97
  896. data/ext/third_party/asio/asio/src/doc/requirements/EndpointSequence.qbk +0 -30
  897. data/ext/third_party/asio/asio/src/doc/requirements/ExecutionContext.qbk +0 -36
  898. data/ext/third_party/asio/asio/src/doc/requirements/Executor.qbk +0 -141
  899. data/ext/third_party/asio/asio/src/doc/requirements/GettableSerialPortOption.qbk +0 -33
  900. data/ext/third_party/asio/asio/src/doc/requirements/GettableSocketOption.qbk +0 -67
  901. data/ext/third_party/asio/asio/src/doc/requirements/Handler.qbk +0 -64
  902. data/ext/third_party/asio/asio/src/doc/requirements/HandshakeHandler.qbk +0 -72
  903. data/ext/third_party/asio/asio/src/doc/requirements/InternetProtocol.qbk +0 -47
  904. data/ext/third_party/asio/asio/src/doc/requirements/IoControlCommand.qbk +0 -34
  905. data/ext/third_party/asio/asio/src/doc/requirements/IoObjectService.qbk +0 -62
  906. data/ext/third_party/asio/asio/src/doc/requirements/IteratorConnectHandler.qbk +0 -81
  907. data/ext/third_party/asio/asio/src/doc/requirements/LegacyCompletionHandler.qbk +0 -65
  908. data/ext/third_party/asio/asio/src/doc/requirements/MoveAcceptHandler.qbk +0 -61
  909. data/ext/third_party/asio/asio/src/doc/requirements/MutableBufferSequence.qbk +0 -54
  910. data/ext/third_party/asio/asio/src/doc/requirements/ProtoAllocator.qbk +0 -19
  911. data/ext/third_party/asio/asio/src/doc/requirements/Protocol.qbk +0 -56
  912. data/ext/third_party/asio/asio/src/doc/requirements/RangeConnectHandler.qbk +0 -82
  913. data/ext/third_party/asio/asio/src/doc/requirements/ReadHandler.qbk +0 -79
  914. data/ext/third_party/asio/asio/src/doc/requirements/ResolveHandler.qbk +0 -82
  915. data/ext/third_party/asio/asio/src/doc/requirements/Service.qbk +0 -40
  916. data/ext/third_party/asio/asio/src/doc/requirements/SettableSerialPortOption.qbk +0 -33
  917. data/ext/third_party/asio/asio/src/doc/requirements/SettableSocketOption.qbk +0 -54
  918. data/ext/third_party/asio/asio/src/doc/requirements/ShutdownHandler.qbk +0 -72
  919. data/ext/third_party/asio/asio/src/doc/requirements/SignalHandler.qbk +0 -79
  920. data/ext/third_party/asio/asio/src/doc/requirements/SyncRandomAccessReadDevice.qbk +0 -49
  921. data/ext/third_party/asio/asio/src/doc/requirements/SyncRandomAccessWriteDevice.qbk +0 -49
  922. data/ext/third_party/asio/asio/src/doc/requirements/SyncReadStream.qbk +0 -41
  923. data/ext/third_party/asio/asio/src/doc/requirements/SyncWriteStream.qbk +0 -39
  924. data/ext/third_party/asio/asio/src/doc/requirements/TimeTraits.qbk +0 -72
  925. data/ext/third_party/asio/asio/src/doc/requirements/WaitHandler.qbk +0 -72
  926. data/ext/third_party/asio/asio/src/doc/requirements/WaitTraits.qbk +0 -52
  927. data/ext/third_party/asio/asio/src/doc/requirements/WriteHandler.qbk +0 -79
  928. data/ext/third_party/asio/asio/src/doc/requirements/asynchronous_operations.qbk +0 -300
  929. data/ext/third_party/asio/asio/src/doc/requirements/asynchronous_socket_operations.qbk +0 -39
  930. data/ext/third_party/asio/asio/src/doc/requirements/read_write_operations.qbk +0 -34
  931. data/ext/third_party/asio/asio/src/doc/requirements/synchronous_socket_operations.qbk +0 -37
  932. data/ext/third_party/asio/asio/src/doc/std_exception_dox.txt +0 -7
  933. data/ext/third_party/asio/asio/src/doc/tutorial.dox +0 -226
  934. data/ext/third_party/asio/asio/src/doc/tutorial.qbk +0 -2387
  935. data/ext/third_party/asio/asio/src/doc/tutorial.xsl +0 -437
  936. data/ext/third_party/asio/asio/src/doc/using.qbk +0 -309
  937. data/ext/third_party/asio/asio/tsify.pl +0 -574
  938. data/ext/third_party/gsl/.clang-format +0 -34
  939. data/ext/third_party/gsl/.github/workflows/main.yml +0 -94
  940. data/ext/third_party/gsl/.gitignore +0 -16
  941. data/ext/third_party/gsl/.travis.yml +0 -551
  942. data/ext/third_party/gsl/CMakeSettings.json +0 -18
  943. data/ext/third_party/gsl/CONTRIBUTING.md +0 -29
  944. data/ext/third_party/gsl/GSL.natvis +0 -98
  945. data/ext/third_party/gsl/README.md +0 -124
  946. data/ext/third_party/gsl/appveyor.yml +0 -128
  947. data/ext/third_party/http_parser/.gitignore +0 -30
  948. data/ext/third_party/http_parser/.mailmap +0 -8
  949. data/ext/third_party/http_parser/.travis.yml +0 -13
  950. data/ext/third_party/http_parser/AUTHORS +0 -68
  951. data/ext/third_party/http_parser/Makefile +0 -160
  952. data/ext/third_party/http_parser/README.md +0 -246
  953. data/ext/third_party/http_parser/bench.c +0 -128
  954. data/ext/third_party/http_parser/http_parser.gyp +0 -111
  955. data/ext/third_party/http_parser/test.c +0 -4600
  956. data/ext/third_party/json/.appveyor.yml +0 -44
  957. data/ext/third_party/json/.clang-format +0 -84
  958. data/ext/third_party/json/.conan/build.py +0 -80
  959. data/ext/third_party/json/.conan/test_package/CMakeLists.txt +0 -12
  960. data/ext/third_party/json/.conan/test_package/conanfile.py +0 -24
  961. data/ext/third_party/json/.conan/test_package/test_package.cpp +0 -16
  962. data/ext/third_party/json/.gitignore +0 -3
  963. data/ext/third_party/json/.travis.yml +0 -173
  964. data/ext/third_party/json/Makefile +0 -77
  965. data/ext/third_party/json/README.md +0 -149
  966. data/ext/third_party/json/conanfile.py +0 -28
  967. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/analyze_cycles.hpp +0 -127
  968. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/counted.hpp +0 -23
  969. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/generic.hpp +0 -31
  970. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/grammar_info.hpp +0 -32
  971. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/insert_guard.hpp +0 -51
  972. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/insert_rules.hpp +0 -25
  973. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/rule_info.hpp +0 -29
  974. data/ext/third_party/json/include/tao/json/external/pegtl/analysis/rule_type.hpp +0 -21
  975. data/ext/third_party/json/include/tao/json/external/pegtl/analyze.hpp +0 -21
  976. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/counter.hpp +0 -54
  977. data/ext/third_party/json/include/tao/json/external/pegtl/contrib/tracer.hpp +0 -158
  978. data/ext/third_party/json/include/tao/json/external/pegtl/internal/alnum.hpp +0 -18
  979. data/ext/third_party/json/include/tao/json/external/pegtl/internal/alpha.hpp +0 -18
  980. data/ext/third_party/json/include/tao/json/external/pegtl/internal/dusel_mode.hpp +0 -23
  981. data/ext/third_party/json/include/tao/json/external/pegtl/internal/duseltronik.hpp +0 -187
  982. data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_opener.hpp +0 -72
  983. data/ext/third_party/json/include/tao/json/external/pegtl/internal/trivial.hpp +0 -32
  984. data/ext/third_party/snappy/.appveyor.yml +0 -36
  985. data/ext/third_party/snappy/.gitignore +0 -8
  986. data/ext/third_party/snappy/.travis.yml +0 -98
  987. data/ext/third_party/snappy/AUTHORS +0 -1
  988. data/ext/third_party/snappy/CONTRIBUTING.md +0 -26
  989. data/ext/third_party/snappy/NEWS +0 -188
  990. data/ext/third_party/snappy/README.md +0 -148
  991. data/ext/third_party/snappy/docs/README.md +0 -72
  992. data/ext/third_party/snappy/format_description.txt +0 -110
  993. data/ext/third_party/snappy/framing_format.txt +0 -135
  994. data/ext/third_party/snappy/snappy-test.cc +0 -613
  995. data/ext/third_party/snappy/snappy-test.h +0 -526
  996. data/ext/third_party/snappy/snappy_compress_fuzzer.cc +0 -60
  997. data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +0 -58
  998. data/ext/third_party/snappy/snappy_unittest.cc +0 -1512
  999. data/ext/third_party/spdlog/.clang-format +0 -108
  1000. data/ext/third_party/spdlog/.clang-tidy +0 -54
  1001. data/ext/third_party/spdlog/.gitattributes +0 -1
  1002. data/ext/third_party/spdlog/.gitignore +0 -83
  1003. data/ext/third_party/spdlog/.travis.yml +0 -112
  1004. data/ext/third_party/spdlog/INSTALL +0 -24
  1005. data/ext/third_party/spdlog/README.md +0 -423
  1006. data/ext/third_party/spdlog/appveyor.yml +0 -51
  1007. data/ext/third_party/spdlog/include/spdlog/cfg/log_levels.h +0 -47
@@ -1,128 +0,0 @@
1
- /* Copyright Fedor Indutny. All rights reserved.
2
- *
3
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4
- * of this software and associated documentation files (the "Software"), to
5
- * deal in the Software without restriction, including without limitation the
6
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- * sell copies of the Software, and to permit persons to whom the Software is
8
- * furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in
11
- * all copies or substantial portions of the Software.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
- * IN THE SOFTWARE.
20
- */
21
- #include "http_parser.h"
22
- #include <assert.h>
23
- #include <stdint.h>
24
- #include <stdio.h>
25
- #include <string.h>
26
- #include <sys/time.h>
27
-
28
- /* 8 gb */
29
- static const int64_t kBytes = 8LL << 30;
30
-
31
- static const char data[] =
32
- "POST /joyent/http-parser HTTP/1.1\r\n"
33
- "Host: github.com\r\n"
34
- "DNT: 1\r\n"
35
- "Accept-Encoding: gzip, deflate, sdch\r\n"
36
- "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4\r\n"
37
- "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) "
38
- "AppleWebKit/537.36 (KHTML, like Gecko) "
39
- "Chrome/39.0.2171.65 Safari/537.36\r\n"
40
- "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,"
41
- "image/webp,*/*;q=0.8\r\n"
42
- "Referer: https://github.com/joyent/http-parser\r\n"
43
- "Connection: keep-alive\r\n"
44
- "Transfer-Encoding: chunked\r\n"
45
- "Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n";
46
- static const size_t data_len = sizeof(data) - 1;
47
-
48
- static int on_info(http_parser* p) {
49
- return 0;
50
- }
51
-
52
-
53
- static int on_data(http_parser* p, const char *at, size_t length) {
54
- return 0;
55
- }
56
-
57
- static http_parser_settings settings = {
58
- .on_message_begin = on_info,
59
- .on_headers_complete = on_info,
60
- .on_message_complete = on_info,
61
- .on_header_field = on_data,
62
- .on_header_value = on_data,
63
- .on_url = on_data,
64
- .on_status = on_data,
65
- .on_body = on_data
66
- };
67
-
68
- int bench(int iter_count, int silent) {
69
- struct http_parser parser;
70
- int i;
71
- int err;
72
- struct timeval start;
73
- struct timeval end;
74
-
75
- if (!silent) {
76
- err = gettimeofday(&start, NULL);
77
- assert(err == 0);
78
- }
79
-
80
- fprintf(stderr, "req_len=%d\n", (int) data_len);
81
- for (i = 0; i < iter_count; i++) {
82
- size_t parsed;
83
- http_parser_init(&parser, HTTP_REQUEST);
84
-
85
- parsed = http_parser_execute(&parser, &settings, data, data_len);
86
- assert(parsed == data_len);
87
- }
88
-
89
- if (!silent) {
90
- double elapsed;
91
- double bw;
92
- double total;
93
-
94
- err = gettimeofday(&end, NULL);
95
- assert(err == 0);
96
-
97
- fprintf(stdout, "Benchmark result:\n");
98
-
99
- elapsed = (double) (end.tv_sec - start.tv_sec) +
100
- (end.tv_usec - start.tv_usec) * 1e-6f;
101
-
102
- total = (double) iter_count * data_len;
103
- bw = (double) total / elapsed;
104
-
105
- fprintf(stdout, "%.2f mb | %.2f mb/s | %.2f req/sec | %.2f s\n",
106
- (double) total / (1024 * 1024),
107
- bw / (1024 * 1024),
108
- (double) iter_count / elapsed,
109
- elapsed);
110
-
111
- fflush(stdout);
112
- }
113
-
114
- return 0;
115
- }
116
-
117
- int main(int argc, char** argv) {
118
- int64_t iterations;
119
-
120
- iterations = kBytes / (int64_t) data_len;
121
- if (argc == 2 && strcmp(argv[1], "infinite") == 0) {
122
- for (;;)
123
- bench(iterations, 1);
124
- return 0;
125
- } else {
126
- return bench(iterations, 0);
127
- }
128
- }
@@ -1,111 +0,0 @@
1
- # This file is used with the GYP meta build system.
2
- # http://code.google.com/p/gyp/
3
- # To build try this:
4
- # svn co http://gyp.googlecode.com/svn/trunk gyp
5
- # ./gyp/gyp -f make --depth=`pwd` http_parser.gyp
6
- # ./out/Debug/test
7
- {
8
- 'target_defaults': {
9
- 'default_configuration': 'Debug',
10
- 'configurations': {
11
- # TODO: hoist these out and put them somewhere common, because
12
- # RuntimeLibrary MUST MATCH across the entire project
13
- 'Debug': {
14
- 'defines': [ 'DEBUG', '_DEBUG' ],
15
- 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ],
16
- 'msvs_settings': {
17
- 'VCCLCompilerTool': {
18
- 'RuntimeLibrary': 1, # static debug
19
- },
20
- },
21
- },
22
- 'Release': {
23
- 'defines': [ 'NDEBUG' ],
24
- 'cflags': [ '-Wall', '-Wextra', '-O3' ],
25
- 'msvs_settings': {
26
- 'VCCLCompilerTool': {
27
- 'RuntimeLibrary': 0, # static release
28
- },
29
- },
30
- }
31
- },
32
- 'msvs_settings': {
33
- 'VCCLCompilerTool': {
34
- },
35
- 'VCLibrarianTool': {
36
- },
37
- 'VCLinkerTool': {
38
- 'GenerateDebugInformation': 'true',
39
- },
40
- },
41
- 'conditions': [
42
- ['OS == "win"', {
43
- 'defines': [
44
- 'WIN32'
45
- ],
46
- }]
47
- ],
48
- },
49
-
50
- 'targets': [
51
- {
52
- 'target_name': 'http_parser',
53
- 'type': 'static_library',
54
- 'include_dirs': [ '.' ],
55
- 'direct_dependent_settings': {
56
- 'defines': [ 'HTTP_PARSER_STRICT=0' ],
57
- 'include_dirs': [ '.' ],
58
- },
59
- 'defines': [ 'HTTP_PARSER_STRICT=0' ],
60
- 'sources': [ './http_parser.c', ],
61
- 'conditions': [
62
- ['OS=="win"', {
63
- 'msvs_settings': {
64
- 'VCCLCompilerTool': {
65
- # Compile as C++. http_parser.c is actually C99, but C++ is
66
- # close enough in this case.
67
- 'CompileAs': 2,
68
- },
69
- },
70
- }]
71
- ],
72
- },
73
-
74
- {
75
- 'target_name': 'http_parser_strict',
76
- 'type': 'static_library',
77
- 'include_dirs': [ '.' ],
78
- 'direct_dependent_settings': {
79
- 'defines': [ 'HTTP_PARSER_STRICT=1' ],
80
- 'include_dirs': [ '.' ],
81
- },
82
- 'defines': [ 'HTTP_PARSER_STRICT=1' ],
83
- 'sources': [ './http_parser.c', ],
84
- 'conditions': [
85
- ['OS=="win"', {
86
- 'msvs_settings': {
87
- 'VCCLCompilerTool': {
88
- # Compile as C++. http_parser.c is actually C99, but C++ is
89
- # close enough in this case.
90
- 'CompileAs': 2,
91
- },
92
- },
93
- }]
94
- ],
95
- },
96
-
97
- {
98
- 'target_name': 'test-nonstrict',
99
- 'type': 'executable',
100
- 'dependencies': [ 'http_parser' ],
101
- 'sources': [ 'test.c' ]
102
- },
103
-
104
- {
105
- 'target_name': 'test-strict',
106
- 'type': 'executable',
107
- 'dependencies': [ 'http_parser_strict' ],
108
- 'sources': [ 'test.c' ]
109
- }
110
- ]
111
- }
@@ -1,4600 +0,0 @@
1
- /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
- *
3
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4
- * of this software and associated documentation files (the "Software"), to
5
- * deal in the Software without restriction, including without limitation the
6
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- * sell copies of the Software, and to permit persons to whom the Software is
8
- * furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in
11
- * all copies or substantial portions of the Software.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
- * IN THE SOFTWARE.
20
- */
21
- #include "http_parser.h"
22
- #include <stdlib.h>
23
- #include <assert.h>
24
- #include <stdio.h>
25
- #include <stdlib.h> /* rand */
26
- #include <string.h>
27
- #include <stdarg.h>
28
-
29
- #if defined(__APPLE__)
30
- # undef strlncpy
31
- #endif /* defined(__APPLE__) */
32
-
33
- #undef TRUE
34
- #define TRUE 1
35
- #undef FALSE
36
- #define FALSE 0
37
-
38
- #define MAX_HEADERS 13
39
- #define MAX_ELEMENT_SIZE 2048
40
- #define MAX_CHUNKS 16
41
-
42
- #define MIN(a,b) ((a) < (b) ? (a) : (b))
43
-
44
- #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
45
-
46
- static http_parser parser;
47
-
48
- struct message {
49
- const char *name; // for debugging purposes
50
- const char *raw;
51
- enum http_parser_type type;
52
- enum http_method method;
53
- int status_code;
54
- char response_status[MAX_ELEMENT_SIZE];
55
- char request_path[MAX_ELEMENT_SIZE];
56
- char request_url[MAX_ELEMENT_SIZE];
57
- char fragment[MAX_ELEMENT_SIZE];
58
- char query_string[MAX_ELEMENT_SIZE];
59
- char body[MAX_ELEMENT_SIZE];
60
- size_t body_size;
61
- const char *host;
62
- const char *userinfo;
63
- uint16_t port;
64
- int num_headers;
65
- enum { NONE=0, FIELD, VALUE } last_header_element;
66
- char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE];
67
- int should_keep_alive;
68
-
69
- int num_chunks;
70
- int num_chunks_complete;
71
- int chunk_lengths[MAX_CHUNKS];
72
-
73
- const char *upgrade; // upgraded body
74
-
75
- unsigned short http_major;
76
- unsigned short http_minor;
77
-
78
- int message_begin_cb_called;
79
- int headers_complete_cb_called;
80
- int message_complete_cb_called;
81
- int status_cb_called;
82
- int message_complete_on_eof;
83
- int body_is_final;
84
- };
85
-
86
- static int currently_parsing_eof;
87
-
88
- static struct message messages[5];
89
- static int num_messages;
90
- static http_parser_settings *current_pause_parser;
91
-
92
- /* * R E Q U E S T S * */
93
- const struct message requests[] =
94
- #define CURL_GET 0
95
- { {.name= "curl get"
96
- ,.type= HTTP_REQUEST
97
- ,.raw= "GET /test HTTP/1.1\r\n"
98
- "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n"
99
- "Host: 0.0.0.0=5000\r\n"
100
- "Accept: */*\r\n"
101
- "\r\n"
102
- ,.should_keep_alive= TRUE
103
- ,.message_complete_on_eof= FALSE
104
- ,.http_major= 1
105
- ,.http_minor= 1
106
- ,.method= HTTP_GET
107
- ,.query_string= ""
108
- ,.fragment= ""
109
- ,.request_path= "/test"
110
- ,.request_url= "/test"
111
- ,.num_headers= 3
112
- ,.headers=
113
- { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" }
114
- , { "Host", "0.0.0.0=5000" }
115
- , { "Accept", "*/*" }
116
- }
117
- ,.body= ""
118
- }
119
-
120
- #define FIREFOX_GET 1
121
- , {.name= "firefox get"
122
- ,.type= HTTP_REQUEST
123
- ,.raw= "GET /favicon.ico HTTP/1.1\r\n"
124
- "Host: 0.0.0.0=5000\r\n"
125
- "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n"
126
- "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
127
- "Accept-Language: en-us,en;q=0.5\r\n"
128
- "Accept-Encoding: gzip,deflate\r\n"
129
- "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
130
- "Keep-Alive: 300\r\n"
131
- "Connection: keep-alive\r\n"
132
- "\r\n"
133
- ,.should_keep_alive= TRUE
134
- ,.message_complete_on_eof= FALSE
135
- ,.http_major= 1
136
- ,.http_minor= 1
137
- ,.method= HTTP_GET
138
- ,.query_string= ""
139
- ,.fragment= ""
140
- ,.request_path= "/favicon.ico"
141
- ,.request_url= "/favicon.ico"
142
- ,.num_headers= 8
143
- ,.headers=
144
- { { "Host", "0.0.0.0=5000" }
145
- , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" }
146
- , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" }
147
- , { "Accept-Language", "en-us,en;q=0.5" }
148
- , { "Accept-Encoding", "gzip,deflate" }
149
- , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" }
150
- , { "Keep-Alive", "300" }
151
- , { "Connection", "keep-alive" }
152
- }
153
- ,.body= ""
154
- }
155
-
156
- #define DUMBLUCK 2
157
- , {.name= "dumbluck"
158
- ,.type= HTTP_REQUEST
159
- ,.raw= "GET /dumbluck HTTP/1.1\r\n"
160
- "aaaaaaaaaaaaa:++++++++++\r\n"
161
- "\r\n"
162
- ,.should_keep_alive= TRUE
163
- ,.message_complete_on_eof= FALSE
164
- ,.http_major= 1
165
- ,.http_minor= 1
166
- ,.method= HTTP_GET
167
- ,.query_string= ""
168
- ,.fragment= ""
169
- ,.request_path= "/dumbluck"
170
- ,.request_url= "/dumbluck"
171
- ,.num_headers= 1
172
- ,.headers=
173
- { { "aaaaaaaaaaaaa", "++++++++++" }
174
- }
175
- ,.body= ""
176
- }
177
-
178
- #define FRAGMENT_IN_URI 3
179
- , {.name= "fragment in url"
180
- ,.type= HTTP_REQUEST
181
- ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n"
182
- "\r\n"
183
- ,.should_keep_alive= TRUE
184
- ,.message_complete_on_eof= FALSE
185
- ,.http_major= 1
186
- ,.http_minor= 1
187
- ,.method= HTTP_GET
188
- ,.query_string= "page=1"
189
- ,.fragment= "posts-17408"
190
- ,.request_path= "/forums/1/topics/2375"
191
- /* XXX request url does include fragment? */
192
- ,.request_url= "/forums/1/topics/2375?page=1#posts-17408"
193
- ,.num_headers= 0
194
- ,.body= ""
195
- }
196
-
197
- #define GET_NO_HEADERS_NO_BODY 4
198
- , {.name= "get no headers no body"
199
- ,.type= HTTP_REQUEST
200
- ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n"
201
- "\r\n"
202
- ,.should_keep_alive= TRUE
203
- ,.message_complete_on_eof= FALSE /* would need Connection: close */
204
- ,.http_major= 1
205
- ,.http_minor= 1
206
- ,.method= HTTP_GET
207
- ,.query_string= ""
208
- ,.fragment= ""
209
- ,.request_path= "/get_no_headers_no_body/world"
210
- ,.request_url= "/get_no_headers_no_body/world"
211
- ,.num_headers= 0
212
- ,.body= ""
213
- }
214
-
215
- #define GET_ONE_HEADER_NO_BODY 5
216
- , {.name= "get one header no body"
217
- ,.type= HTTP_REQUEST
218
- ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n"
219
- "Accept: */*\r\n"
220
- "\r\n"
221
- ,.should_keep_alive= TRUE
222
- ,.message_complete_on_eof= FALSE /* would need Connection: close */
223
- ,.http_major= 1
224
- ,.http_minor= 1
225
- ,.method= HTTP_GET
226
- ,.query_string= ""
227
- ,.fragment= ""
228
- ,.request_path= "/get_one_header_no_body"
229
- ,.request_url= "/get_one_header_no_body"
230
- ,.num_headers= 1
231
- ,.headers=
232
- { { "Accept" , "*/*" }
233
- }
234
- ,.body= ""
235
- }
236
-
237
- #define GET_FUNKY_CONTENT_LENGTH 6
238
- , {.name= "get funky content length body hello"
239
- ,.type= HTTP_REQUEST
240
- ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n"
241
- "conTENT-Length: 5\r\n"
242
- "\r\n"
243
- "HELLO"
244
- ,.should_keep_alive= FALSE
245
- ,.message_complete_on_eof= FALSE
246
- ,.http_major= 1
247
- ,.http_minor= 0
248
- ,.method= HTTP_GET
249
- ,.query_string= ""
250
- ,.fragment= ""
251
- ,.request_path= "/get_funky_content_length_body_hello"
252
- ,.request_url= "/get_funky_content_length_body_hello"
253
- ,.num_headers= 1
254
- ,.headers=
255
- { { "conTENT-Length" , "5" }
256
- }
257
- ,.body= "HELLO"
258
- }
259
-
260
- #define POST_IDENTITY_BODY_WORLD 7
261
- , {.name= "post identity body world"
262
- ,.type= HTTP_REQUEST
263
- ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n"
264
- "Accept: */*\r\n"
265
- "Content-Length: 5\r\n"
266
- "\r\n"
267
- "World"
268
- ,.should_keep_alive= TRUE
269
- ,.message_complete_on_eof= FALSE
270
- ,.http_major= 1
271
- ,.http_minor= 1
272
- ,.method= HTTP_POST
273
- ,.query_string= "q=search"
274
- ,.fragment= "hey"
275
- ,.request_path= "/post_identity_body_world"
276
- ,.request_url= "/post_identity_body_world?q=search#hey"
277
- ,.num_headers= 2
278
- ,.headers=
279
- { { "Accept", "*/*" }
280
- , { "Content-Length", "5" }
281
- }
282
- ,.body= "World"
283
- }
284
-
285
- #define POST_CHUNKED_ALL_YOUR_BASE 8
286
- , {.name= "post - chunked body: all your base are belong to us"
287
- ,.type= HTTP_REQUEST
288
- ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n"
289
- "Transfer-Encoding: chunked\r\n"
290
- "\r\n"
291
- "1e\r\nall your base are belong to us\r\n"
292
- "0\r\n"
293
- "\r\n"
294
- ,.should_keep_alive= TRUE
295
- ,.message_complete_on_eof= FALSE
296
- ,.http_major= 1
297
- ,.http_minor= 1
298
- ,.method= HTTP_POST
299
- ,.query_string= ""
300
- ,.fragment= ""
301
- ,.request_path= "/post_chunked_all_your_base"
302
- ,.request_url= "/post_chunked_all_your_base"
303
- ,.num_headers= 1
304
- ,.headers=
305
- { { "Transfer-Encoding" , "chunked" }
306
- }
307
- ,.body= "all your base are belong to us"
308
- ,.num_chunks_complete= 2
309
- ,.chunk_lengths= { 0x1e }
310
- }
311
-
312
- #define TWO_CHUNKS_MULT_ZERO_END 9
313
- , {.name= "two chunks ; triple zero ending"
314
- ,.type= HTTP_REQUEST
315
- ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n"
316
- "Transfer-Encoding: chunked\r\n"
317
- "\r\n"
318
- "5\r\nhello\r\n"
319
- "6\r\n world\r\n"
320
- "000\r\n"
321
- "\r\n"
322
- ,.should_keep_alive= TRUE
323
- ,.message_complete_on_eof= FALSE
324
- ,.http_major= 1
325
- ,.http_minor= 1
326
- ,.method= HTTP_POST
327
- ,.query_string= ""
328
- ,.fragment= ""
329
- ,.request_path= "/two_chunks_mult_zero_end"
330
- ,.request_url= "/two_chunks_mult_zero_end"
331
- ,.num_headers= 1
332
- ,.headers=
333
- { { "Transfer-Encoding", "chunked" }
334
- }
335
- ,.body= "hello world"
336
- ,.num_chunks_complete= 3
337
- ,.chunk_lengths= { 5, 6 }
338
- }
339
-
340
- #define CHUNKED_W_TRAILING_HEADERS 10
341
- , {.name= "chunked with trailing headers. blech."
342
- ,.type= HTTP_REQUEST
343
- ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n"
344
- "Transfer-Encoding: chunked\r\n"
345
- "\r\n"
346
- "5\r\nhello\r\n"
347
- "6\r\n world\r\n"
348
- "0\r\n"
349
- "Vary: *\r\n"
350
- "Content-Type: text/plain\r\n"
351
- "\r\n"
352
- ,.should_keep_alive= TRUE
353
- ,.message_complete_on_eof= FALSE
354
- ,.http_major= 1
355
- ,.http_minor= 1
356
- ,.method= HTTP_POST
357
- ,.query_string= ""
358
- ,.fragment= ""
359
- ,.request_path= "/chunked_w_trailing_headers"
360
- ,.request_url= "/chunked_w_trailing_headers"
361
- ,.num_headers= 3
362
- ,.headers=
363
- { { "Transfer-Encoding", "chunked" }
364
- , { "Vary", "*" }
365
- , { "Content-Type", "text/plain" }
366
- }
367
- ,.body= "hello world"
368
- ,.num_chunks_complete= 3
369
- ,.chunk_lengths= { 5, 6 }
370
- }
371
-
372
- #define CHUNKED_W_NONSENSE_AFTER_LENGTH 11
373
- , {.name= "with nonsense after the length"
374
- ,.type= HTTP_REQUEST
375
- ,.raw= "POST /chunked_w_nonsense_after_length HTTP/1.1\r\n"
376
- "Transfer-Encoding: chunked\r\n"
377
- "\r\n"
378
- "5; ilovew3;whattheluck=aretheseparametersfor\r\nhello\r\n"
379
- "6; blahblah; blah\r\n world\r\n"
380
- "0\r\n"
381
- "\r\n"
382
- ,.should_keep_alive= TRUE
383
- ,.message_complete_on_eof= FALSE
384
- ,.http_major= 1
385
- ,.http_minor= 1
386
- ,.method= HTTP_POST
387
- ,.query_string= ""
388
- ,.fragment= ""
389
- ,.request_path= "/chunked_w_nonsense_after_length"
390
- ,.request_url= "/chunked_w_nonsense_after_length"
391
- ,.num_headers= 1
392
- ,.headers=
393
- { { "Transfer-Encoding", "chunked" }
394
- }
395
- ,.body= "hello world"
396
- ,.num_chunks_complete= 3
397
- ,.chunk_lengths= { 5, 6 }
398
- }
399
-
400
- #define WITH_QUOTES 12
401
- , {.name= "with quotes"
402
- ,.type= HTTP_REQUEST
403
- ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n"
404
- ,.should_keep_alive= TRUE
405
- ,.message_complete_on_eof= FALSE
406
- ,.http_major= 1
407
- ,.http_minor= 1
408
- ,.method= HTTP_GET
409
- ,.query_string= "foo=\"bar\""
410
- ,.fragment= ""
411
- ,.request_path= "/with_\"stupid\"_quotes"
412
- ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\""
413
- ,.num_headers= 0
414
- ,.headers= { }
415
- ,.body= ""
416
- }
417
-
418
- #define APACHEBENCH_GET 13
419
- /* The server receiving this request SHOULD NOT wait for EOF
420
- * to know that content-length == 0.
421
- * How to represent this in a unit test? message_complete_on_eof
422
- * Compare with NO_CONTENT_LENGTH_RESPONSE.
423
- */
424
- , {.name = "apachebench get"
425
- ,.type= HTTP_REQUEST
426
- ,.raw= "GET /test HTTP/1.0\r\n"
427
- "Host: 0.0.0.0:5000\r\n"
428
- "User-Agent: ApacheBench/2.3\r\n"
429
- "Accept: */*\r\n\r\n"
430
- ,.should_keep_alive= FALSE
431
- ,.message_complete_on_eof= FALSE
432
- ,.http_major= 1
433
- ,.http_minor= 0
434
- ,.method= HTTP_GET
435
- ,.query_string= ""
436
- ,.fragment= ""
437
- ,.request_path= "/test"
438
- ,.request_url= "/test"
439
- ,.num_headers= 3
440
- ,.headers= { { "Host", "0.0.0.0:5000" }
441
- , { "User-Agent", "ApacheBench/2.3" }
442
- , { "Accept", "*/*" }
443
- }
444
- ,.body= ""
445
- }
446
-
447
- #define QUERY_URL_WITH_QUESTION_MARK_GET 14
448
- /* Some clients include '?' characters in query strings.
449
- */
450
- , {.name = "query url with question mark"
451
- ,.type= HTTP_REQUEST
452
- ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n"
453
- ,.should_keep_alive= TRUE
454
- ,.message_complete_on_eof= FALSE
455
- ,.http_major= 1
456
- ,.http_minor= 1
457
- ,.method= HTTP_GET
458
- ,.query_string= "foo=bar?baz"
459
- ,.fragment= ""
460
- ,.request_path= "/test.cgi"
461
- ,.request_url= "/test.cgi?foo=bar?baz"
462
- ,.num_headers= 0
463
- ,.headers= {}
464
- ,.body= ""
465
- }
466
-
467
- #define PREFIX_NEWLINE_GET 15
468
- /* Some clients, especially after a POST in a keep-alive connection,
469
- * will send an extra CRLF before the next request
470
- */
471
- , {.name = "newline prefix get"
472
- ,.type= HTTP_REQUEST
473
- ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n"
474
- ,.should_keep_alive= TRUE
475
- ,.message_complete_on_eof= FALSE
476
- ,.http_major= 1
477
- ,.http_minor= 1
478
- ,.method= HTTP_GET
479
- ,.query_string= ""
480
- ,.fragment= ""
481
- ,.request_path= "/test"
482
- ,.request_url= "/test"
483
- ,.num_headers= 0
484
- ,.headers= { }
485
- ,.body= ""
486
- }
487
-
488
- #define UPGRADE_REQUEST 16
489
- , {.name = "upgrade request"
490
- ,.type= HTTP_REQUEST
491
- ,.raw= "GET /demo HTTP/1.1\r\n"
492
- "Host: example.com\r\n"
493
- "Connection: Upgrade\r\n"
494
- "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n"
495
- "Sec-WebSocket-Protocol: sample\r\n"
496
- "Upgrade: WebSocket\r\n"
497
- "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n"
498
- "Origin: http://example.com\r\n"
499
- "\r\n"
500
- "Hot diggity dogg"
501
- ,.should_keep_alive= TRUE
502
- ,.message_complete_on_eof= FALSE
503
- ,.http_major= 1
504
- ,.http_minor= 1
505
- ,.method= HTTP_GET
506
- ,.query_string= ""
507
- ,.fragment= ""
508
- ,.request_path= "/demo"
509
- ,.request_url= "/demo"
510
- ,.num_headers= 7
511
- ,.upgrade="Hot diggity dogg"
512
- ,.headers= { { "Host", "example.com" }
513
- , { "Connection", "Upgrade" }
514
- , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" }
515
- , { "Sec-WebSocket-Protocol", "sample" }
516
- , { "Upgrade", "WebSocket" }
517
- , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" }
518
- , { "Origin", "http://example.com" }
519
- }
520
- ,.body= ""
521
- }
522
-
523
- #define CONNECT_REQUEST 17
524
- , {.name = "connect request"
525
- ,.type= HTTP_REQUEST
526
- ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n"
527
- "User-agent: Mozilla/1.1N\r\n"
528
- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n"
529
- "\r\n"
530
- "some data\r\n"
531
- "and yet even more data"
532
- ,.should_keep_alive= FALSE
533
- ,.message_complete_on_eof= FALSE
534
- ,.http_major= 1
535
- ,.http_minor= 0
536
- ,.method= HTTP_CONNECT
537
- ,.query_string= ""
538
- ,.fragment= ""
539
- ,.request_path= ""
540
- ,.request_url= "0-home0.netscape.com:443"
541
- ,.num_headers= 2
542
- ,.upgrade="some data\r\nand yet even more data"
543
- ,.headers= { { "User-agent", "Mozilla/1.1N" }
544
- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" }
545
- }
546
- ,.body= ""
547
- }
548
-
549
- #define REPORT_REQ 18
550
- , {.name= "report request"
551
- ,.type= HTTP_REQUEST
552
- ,.raw= "REPORT /test HTTP/1.1\r\n"
553
- "\r\n"
554
- ,.should_keep_alive= TRUE
555
- ,.message_complete_on_eof= FALSE
556
- ,.http_major= 1
557
- ,.http_minor= 1
558
- ,.method= HTTP_REPORT
559
- ,.query_string= ""
560
- ,.fragment= ""
561
- ,.request_path= "/test"
562
- ,.request_url= "/test"
563
- ,.num_headers= 0
564
- ,.headers= {}
565
- ,.body= ""
566
- }
567
-
568
- #define NO_HTTP_VERSION 19
569
- , {.name= "request with no http version"
570
- ,.type= HTTP_REQUEST
571
- ,.raw= "GET /\r\n"
572
- "\r\n"
573
- ,.should_keep_alive= FALSE
574
- ,.message_complete_on_eof= FALSE
575
- ,.http_major= 0
576
- ,.http_minor= 9
577
- ,.method= HTTP_GET
578
- ,.query_string= ""
579
- ,.fragment= ""
580
- ,.request_path= "/"
581
- ,.request_url= "/"
582
- ,.num_headers= 0
583
- ,.headers= {}
584
- ,.body= ""
585
- }
586
-
587
- #define MSEARCH_REQ 20
588
- , {.name= "m-search request"
589
- ,.type= HTTP_REQUEST
590
- ,.raw= "M-SEARCH * HTTP/1.1\r\n"
591
- "HOST: 239.255.255.250:1900\r\n"
592
- "MAN: \"ssdp:discover\"\r\n"
593
- "ST: \"ssdp:all\"\r\n"
594
- "\r\n"
595
- ,.should_keep_alive= TRUE
596
- ,.message_complete_on_eof= FALSE
597
- ,.http_major= 1
598
- ,.http_minor= 1
599
- ,.method= HTTP_MSEARCH
600
- ,.query_string= ""
601
- ,.fragment= ""
602
- ,.request_path= "*"
603
- ,.request_url= "*"
604
- ,.num_headers= 3
605
- ,.headers= { { "HOST", "239.255.255.250:1900" }
606
- , { "MAN", "\"ssdp:discover\"" }
607
- , { "ST", "\"ssdp:all\"" }
608
- }
609
- ,.body= ""
610
- }
611
-
612
- #define LINE_FOLDING_IN_HEADER 21
613
- , {.name= "line folding in header value"
614
- ,.type= HTTP_REQUEST
615
- ,.raw= "GET / HTTP/1.1\r\n"
616
- "Line1: abc\r\n"
617
- "\tdef\r\n"
618
- " ghi\r\n"
619
- "\t\tjkl\r\n"
620
- " mno \r\n"
621
- "\t \tqrs\r\n"
622
- "Line2: \t line2\t\r\n"
623
- "Line3:\r\n"
624
- " line3\r\n"
625
- "Line4: \r\n"
626
- " \r\n"
627
- "Connection:\r\n"
628
- " close\r\n"
629
- "\r\n"
630
- ,.should_keep_alive= FALSE
631
- ,.message_complete_on_eof= FALSE
632
- ,.http_major= 1
633
- ,.http_minor= 1
634
- ,.method= HTTP_GET
635
- ,.query_string= ""
636
- ,.fragment= ""
637
- ,.request_path= "/"
638
- ,.request_url= "/"
639
- ,.num_headers= 5
640
- ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
641
- , { "Line2", "line2\t" }
642
- , { "Line3", "line3" }
643
- , { "Line4", "" }
644
- , { "Connection", "close" },
645
- }
646
- ,.body= ""
647
- }
648
-
649
-
650
- #define QUERY_TERMINATED_HOST 22
651
- , {.name= "host terminated by a query string"
652
- ,.type= HTTP_REQUEST
653
- ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n"
654
- "\r\n"
655
- ,.should_keep_alive= TRUE
656
- ,.message_complete_on_eof= FALSE
657
- ,.http_major= 1
658
- ,.http_minor= 1
659
- ,.method= HTTP_GET
660
- ,.query_string= "hail=all"
661
- ,.fragment= ""
662
- ,.request_path= ""
663
- ,.request_url= "http://hypnotoad.org?hail=all"
664
- ,.host= "hypnotoad.org"
665
- ,.num_headers= 0
666
- ,.headers= { }
667
- ,.body= ""
668
- }
669
-
670
- #define QUERY_TERMINATED_HOSTPORT 23
671
- , {.name= "host:port terminated by a query string"
672
- ,.type= HTTP_REQUEST
673
- ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n"
674
- "\r\n"
675
- ,.should_keep_alive= TRUE
676
- ,.message_complete_on_eof= FALSE
677
- ,.http_major= 1
678
- ,.http_minor= 1
679
- ,.method= HTTP_GET
680
- ,.query_string= "hail=all"
681
- ,.fragment= ""
682
- ,.request_path= ""
683
- ,.request_url= "http://hypnotoad.org:1234?hail=all"
684
- ,.host= "hypnotoad.org"
685
- ,.port= 1234
686
- ,.num_headers= 0
687
- ,.headers= { }
688
- ,.body= ""
689
- }
690
-
691
- #define SPACE_TERMINATED_HOSTPORT 24
692
- , {.name= "host:port terminated by a space"
693
- ,.type= HTTP_REQUEST
694
- ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n"
695
- "\r\n"
696
- ,.should_keep_alive= TRUE
697
- ,.message_complete_on_eof= FALSE
698
- ,.http_major= 1
699
- ,.http_minor= 1
700
- ,.method= HTTP_GET
701
- ,.query_string= ""
702
- ,.fragment= ""
703
- ,.request_path= ""
704
- ,.request_url= "http://hypnotoad.org:1234"
705
- ,.host= "hypnotoad.org"
706
- ,.port= 1234
707
- ,.num_headers= 0
708
- ,.headers= { }
709
- ,.body= ""
710
- }
711
-
712
- #define PATCH_REQ 25
713
- , {.name = "PATCH request"
714
- ,.type= HTTP_REQUEST
715
- ,.raw= "PATCH /file.txt HTTP/1.1\r\n"
716
- "Host: www.example.com\r\n"
717
- "Content-Type: application/example\r\n"
718
- "If-Match: \"e0023aa4e\"\r\n"
719
- "Content-Length: 10\r\n"
720
- "\r\n"
721
- "cccccccccc"
722
- ,.should_keep_alive= TRUE
723
- ,.message_complete_on_eof= FALSE
724
- ,.http_major= 1
725
- ,.http_minor= 1
726
- ,.method= HTTP_PATCH
727
- ,.query_string= ""
728
- ,.fragment= ""
729
- ,.request_path= "/file.txt"
730
- ,.request_url= "/file.txt"
731
- ,.num_headers= 4
732
- ,.headers= { { "Host", "www.example.com" }
733
- , { "Content-Type", "application/example" }
734
- , { "If-Match", "\"e0023aa4e\"" }
735
- , { "Content-Length", "10" }
736
- }
737
- ,.body= "cccccccccc"
738
- }
739
-
740
- #define CONNECT_CAPS_REQUEST 26
741
- , {.name = "connect caps request"
742
- ,.type= HTTP_REQUEST
743
- ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n"
744
- "User-agent: Mozilla/1.1N\r\n"
745
- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n"
746
- "\r\n"
747
- ,.should_keep_alive= FALSE
748
- ,.message_complete_on_eof= FALSE
749
- ,.http_major= 1
750
- ,.http_minor= 0
751
- ,.method= HTTP_CONNECT
752
- ,.query_string= ""
753
- ,.fragment= ""
754
- ,.request_path= ""
755
- ,.request_url= "HOME0.NETSCAPE.COM:443"
756
- ,.num_headers= 2
757
- ,.upgrade=""
758
- ,.headers= { { "User-agent", "Mozilla/1.1N" }
759
- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" }
760
- }
761
- ,.body= ""
762
- }
763
-
764
- #if !HTTP_PARSER_STRICT
765
- #define UTF8_PATH_REQ 27
766
- , {.name= "utf-8 path request"
767
- ,.type= HTTP_REQUEST
768
- ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n"
769
- "Host: github.com\r\n"
770
- "\r\n"
771
- ,.should_keep_alive= TRUE
772
- ,.message_complete_on_eof= FALSE
773
- ,.http_major= 1
774
- ,.http_minor= 1
775
- ,.method= HTTP_GET
776
- ,.query_string= "q=1"
777
- ,.fragment= "narf"
778
- ,.request_path= "/δ¶/δt/pope"
779
- ,.request_url= "/δ¶/δt/pope?q=1#narf"
780
- ,.num_headers= 1
781
- ,.headers= { {"Host", "github.com" }
782
- }
783
- ,.body= ""
784
- }
785
-
786
- #define HOSTNAME_UNDERSCORE 28
787
- , {.name = "hostname underscore"
788
- ,.type= HTTP_REQUEST
789
- ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n"
790
- "User-agent: Mozilla/1.1N\r\n"
791
- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n"
792
- "\r\n"
793
- ,.should_keep_alive= FALSE
794
- ,.message_complete_on_eof= FALSE
795
- ,.http_major= 1
796
- ,.http_minor= 0
797
- ,.method= HTTP_CONNECT
798
- ,.query_string= ""
799
- ,.fragment= ""
800
- ,.request_path= ""
801
- ,.request_url= "home_0.netscape.com:443"
802
- ,.num_headers= 2
803
- ,.upgrade=""
804
- ,.headers= { { "User-agent", "Mozilla/1.1N" }
805
- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" }
806
- }
807
- ,.body= ""
808
- }
809
- #endif /* !HTTP_PARSER_STRICT */
810
-
811
- /* see https://github.com/ry/http-parser/issues/47 */
812
- #define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29
813
- , {.name = "eat CRLF between requests, no \"Connection: close\" header"
814
- ,.raw= "POST / HTTP/1.1\r\n"
815
- "Host: www.example.com\r\n"
816
- "Content-Type: application/x-www-form-urlencoded\r\n"
817
- "Content-Length: 4\r\n"
818
- "\r\n"
819
- "q=42\r\n" /* note the trailing CRLF */
820
- ,.should_keep_alive= TRUE
821
- ,.message_complete_on_eof= FALSE
822
- ,.http_major= 1
823
- ,.http_minor= 1
824
- ,.method= HTTP_POST
825
- ,.query_string= ""
826
- ,.fragment= ""
827
- ,.request_path= "/"
828
- ,.request_url= "/"
829
- ,.num_headers= 3
830
- ,.upgrade= 0
831
- ,.headers= { { "Host", "www.example.com" }
832
- , { "Content-Type", "application/x-www-form-urlencoded" }
833
- , { "Content-Length", "4" }
834
- }
835
- ,.body= "q=42"
836
- }
837
-
838
- /* see https://github.com/ry/http-parser/issues/47 */
839
- #define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30
840
- , {.name = "eat CRLF between requests even if \"Connection: close\" is set"
841
- ,.raw= "POST / HTTP/1.1\r\n"
842
- "Host: www.example.com\r\n"
843
- "Content-Type: application/x-www-form-urlencoded\r\n"
844
- "Content-Length: 4\r\n"
845
- "Connection: close\r\n"
846
- "\r\n"
847
- "q=42\r\n" /* note the trailing CRLF */
848
- ,.should_keep_alive= FALSE
849
- ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */
850
- ,.http_major= 1
851
- ,.http_minor= 1
852
- ,.method= HTTP_POST
853
- ,.query_string= ""
854
- ,.fragment= ""
855
- ,.request_path= "/"
856
- ,.request_url= "/"
857
- ,.num_headers= 4
858
- ,.upgrade= 0
859
- ,.headers= { { "Host", "www.example.com" }
860
- , { "Content-Type", "application/x-www-form-urlencoded" }
861
- , { "Content-Length", "4" }
862
- , { "Connection", "close" }
863
- }
864
- ,.body= "q=42"
865
- }
866
-
867
- #define PURGE_REQ 31
868
- , {.name = "PURGE request"
869
- ,.type= HTTP_REQUEST
870
- ,.raw= "PURGE /file.txt HTTP/1.1\r\n"
871
- "Host: www.example.com\r\n"
872
- "\r\n"
873
- ,.should_keep_alive= TRUE
874
- ,.message_complete_on_eof= FALSE
875
- ,.http_major= 1
876
- ,.http_minor= 1
877
- ,.method= HTTP_PURGE
878
- ,.query_string= ""
879
- ,.fragment= ""
880
- ,.request_path= "/file.txt"
881
- ,.request_url= "/file.txt"
882
- ,.num_headers= 1
883
- ,.headers= { { "Host", "www.example.com" } }
884
- ,.body= ""
885
- }
886
-
887
- #define SEARCH_REQ 32
888
- , {.name = "SEARCH request"
889
- ,.type= HTTP_REQUEST
890
- ,.raw= "SEARCH / HTTP/1.1\r\n"
891
- "Host: www.example.com\r\n"
892
- "\r\n"
893
- ,.should_keep_alive= TRUE
894
- ,.message_complete_on_eof= FALSE
895
- ,.http_major= 1
896
- ,.http_minor= 1
897
- ,.method= HTTP_SEARCH
898
- ,.query_string= ""
899
- ,.fragment= ""
900
- ,.request_path= "/"
901
- ,.request_url= "/"
902
- ,.num_headers= 1
903
- ,.headers= { { "Host", "www.example.com" } }
904
- ,.body= ""
905
- }
906
-
907
- #define PROXY_WITH_BASIC_AUTH 33
908
- , {.name= "host:port and basic_auth"
909
- ,.type= HTTP_REQUEST
910
- ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n"
911
- "\r\n"
912
- ,.should_keep_alive= TRUE
913
- ,.message_complete_on_eof= FALSE
914
- ,.http_major= 1
915
- ,.http_minor= 1
916
- ,.method= HTTP_GET
917
- ,.fragment= ""
918
- ,.request_path= "/toto"
919
- ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto"
920
- ,.host= "hypnotoad.org"
921
- ,.userinfo= "a%12:b!&*$"
922
- ,.port= 1234
923
- ,.num_headers= 0
924
- ,.headers= { }
925
- ,.body= ""
926
- }
927
-
928
- #define LINE_FOLDING_IN_HEADER_WITH_LF 34
929
- , {.name= "line folding in header value"
930
- ,.type= HTTP_REQUEST
931
- ,.raw= "GET / HTTP/1.1\n"
932
- "Line1: abc\n"
933
- "\tdef\n"
934
- " ghi\n"
935
- "\t\tjkl\n"
936
- " mno \n"
937
- "\t \tqrs\n"
938
- "Line2: \t line2\t\n"
939
- "Line3:\n"
940
- " line3\n"
941
- "Line4: \n"
942
- " \n"
943
- "Connection:\n"
944
- " close\n"
945
- "\n"
946
- ,.should_keep_alive= FALSE
947
- ,.message_complete_on_eof= FALSE
948
- ,.http_major= 1
949
- ,.http_minor= 1
950
- ,.method= HTTP_GET
951
- ,.query_string= ""
952
- ,.fragment= ""
953
- ,.request_path= "/"
954
- ,.request_url= "/"
955
- ,.num_headers= 5
956
- ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
957
- , { "Line2", "line2\t" }
958
- , { "Line3", "line3" }
959
- , { "Line4", "" }
960
- , { "Connection", "close" },
961
- }
962
- ,.body= ""
963
- }
964
-
965
- #define CONNECTION_MULTI 35
966
- , {.name = "multiple connection header values with folding"
967
- ,.type= HTTP_REQUEST
968
- ,.raw= "GET /demo HTTP/1.1\r\n"
969
- "Host: example.com\r\n"
970
- "Connection: Something,\r\n"
971
- " Upgrade, ,Keep-Alive\r\n"
972
- "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n"
973
- "Sec-WebSocket-Protocol: sample\r\n"
974
- "Upgrade: WebSocket\r\n"
975
- "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n"
976
- "Origin: http://example.com\r\n"
977
- "\r\n"
978
- "Hot diggity dogg"
979
- ,.should_keep_alive= TRUE
980
- ,.message_complete_on_eof= FALSE
981
- ,.http_major= 1
982
- ,.http_minor= 1
983
- ,.method= HTTP_GET
984
- ,.query_string= ""
985
- ,.fragment= ""
986
- ,.request_path= "/demo"
987
- ,.request_url= "/demo"
988
- ,.num_headers= 7
989
- ,.upgrade="Hot diggity dogg"
990
- ,.headers= { { "Host", "example.com" }
991
- , { "Connection", "Something, Upgrade, ,Keep-Alive" }
992
- , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" }
993
- , { "Sec-WebSocket-Protocol", "sample" }
994
- , { "Upgrade", "WebSocket" }
995
- , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" }
996
- , { "Origin", "http://example.com" }
997
- }
998
- ,.body= ""
999
- }
1000
-
1001
- #define CONNECTION_MULTI_LWS 36
1002
- , {.name = "multiple connection header values with folding and lws"
1003
- ,.type= HTTP_REQUEST
1004
- ,.raw= "GET /demo HTTP/1.1\r\n"
1005
- "Connection: keep-alive, upgrade\r\n"
1006
- "Upgrade: WebSocket\r\n"
1007
- "\r\n"
1008
- "Hot diggity dogg"
1009
- ,.should_keep_alive= TRUE
1010
- ,.message_complete_on_eof= FALSE
1011
- ,.http_major= 1
1012
- ,.http_minor= 1
1013
- ,.method= HTTP_GET
1014
- ,.query_string= ""
1015
- ,.fragment= ""
1016
- ,.request_path= "/demo"
1017
- ,.request_url= "/demo"
1018
- ,.num_headers= 2
1019
- ,.upgrade="Hot diggity dogg"
1020
- ,.headers= { { "Connection", "keep-alive, upgrade" }
1021
- , { "Upgrade", "WebSocket" }
1022
- }
1023
- ,.body= ""
1024
- }
1025
-
1026
- #define CONNECTION_MULTI_LWS_CRLF 37
1027
- , {.name = "multiple connection header values with folding and lws"
1028
- ,.type= HTTP_REQUEST
1029
- ,.raw= "GET /demo HTTP/1.1\r\n"
1030
- "Connection: keep-alive, \r\n upgrade\r\n"
1031
- "Upgrade: WebSocket\r\n"
1032
- "\r\n"
1033
- "Hot diggity dogg"
1034
- ,.should_keep_alive= TRUE
1035
- ,.message_complete_on_eof= FALSE
1036
- ,.http_major= 1
1037
- ,.http_minor= 1
1038
- ,.method= HTTP_GET
1039
- ,.query_string= ""
1040
- ,.fragment= ""
1041
- ,.request_path= "/demo"
1042
- ,.request_url= "/demo"
1043
- ,.num_headers= 2
1044
- ,.upgrade="Hot diggity dogg"
1045
- ,.headers= { { "Connection", "keep-alive, upgrade" }
1046
- , { "Upgrade", "WebSocket" }
1047
- }
1048
- ,.body= ""
1049
- }
1050
-
1051
- #define UPGRADE_POST_REQUEST 38
1052
- , {.name = "upgrade post request"
1053
- ,.type= HTTP_REQUEST
1054
- ,.raw= "POST /demo HTTP/1.1\r\n"
1055
- "Host: example.com\r\n"
1056
- "Connection: Upgrade\r\n"
1057
- "Upgrade: HTTP/2.0\r\n"
1058
- "Content-Length: 15\r\n"
1059
- "\r\n"
1060
- "sweet post body"
1061
- "Hot diggity dogg"
1062
- ,.should_keep_alive= TRUE
1063
- ,.message_complete_on_eof= FALSE
1064
- ,.http_major= 1
1065
- ,.http_minor= 1
1066
- ,.method= HTTP_POST
1067
- ,.request_path= "/demo"
1068
- ,.request_url= "/demo"
1069
- ,.num_headers= 4
1070
- ,.upgrade="Hot diggity dogg"
1071
- ,.headers= { { "Host", "example.com" }
1072
- , { "Connection", "Upgrade" }
1073
- , { "Upgrade", "HTTP/2.0" }
1074
- , { "Content-Length", "15" }
1075
- }
1076
- ,.body= "sweet post body"
1077
- }
1078
-
1079
- #define CONNECT_WITH_BODY_REQUEST 39
1080
- , {.name = "connect with body request"
1081
- ,.type= HTTP_REQUEST
1082
- ,.raw= "CONNECT foo.bar.com:443 HTTP/1.0\r\n"
1083
- "User-agent: Mozilla/1.1N\r\n"
1084
- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n"
1085
- "Content-Length: 10\r\n"
1086
- "\r\n"
1087
- "blarfcicle"
1088
- ,.should_keep_alive= FALSE
1089
- ,.message_complete_on_eof= FALSE
1090
- ,.http_major= 1
1091
- ,.http_minor= 0
1092
- ,.method= HTTP_CONNECT
1093
- ,.request_url= "foo.bar.com:443"
1094
- ,.num_headers= 3
1095
- ,.upgrade="blarfcicle"
1096
- ,.headers= { { "User-agent", "Mozilla/1.1N" }
1097
- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" }
1098
- , { "Content-Length", "10" }
1099
- }
1100
- ,.body= ""
1101
- }
1102
-
1103
- /* Examples from the Internet draft for LINK/UNLINK methods:
1104
- * https://tools.ietf.org/id/draft-snell-link-method-01.html#rfc.section.5
1105
- */
1106
-
1107
- #define LINK_REQUEST 40
1108
- , {.name = "link request"
1109
- ,.type= HTTP_REQUEST
1110
- ,.raw= "LINK /images/my_dog.jpg HTTP/1.1\r\n"
1111
- "Host: example.com\r\n"
1112
- "Link: <http://example.com/profiles/joe>; rel=\"tag\"\r\n"
1113
- "Link: <http://example.com/profiles/sally>; rel=\"tag\"\r\n"
1114
- "\r\n"
1115
- ,.should_keep_alive= TRUE
1116
- ,.message_complete_on_eof= FALSE
1117
- ,.http_major= 1
1118
- ,.http_minor= 1
1119
- ,.method= HTTP_LINK
1120
- ,.request_path= "/images/my_dog.jpg"
1121
- ,.request_url= "/images/my_dog.jpg"
1122
- ,.query_string= ""
1123
- ,.fragment= ""
1124
- ,.num_headers= 3
1125
- ,.headers= { { "Host", "example.com" }
1126
- , { "Link", "<http://example.com/profiles/joe>; rel=\"tag\"" }
1127
- , { "Link", "<http://example.com/profiles/sally>; rel=\"tag\"" }
1128
- }
1129
- ,.body= ""
1130
- }
1131
-
1132
- #define UNLINK_REQUEST 41
1133
- , {.name = "unlink request"
1134
- ,.type= HTTP_REQUEST
1135
- ,.raw= "UNLINK /images/my_dog.jpg HTTP/1.1\r\n"
1136
- "Host: example.com\r\n"
1137
- "Link: <http://example.com/profiles/sally>; rel=\"tag\"\r\n"
1138
- "\r\n"
1139
- ,.should_keep_alive= TRUE
1140
- ,.message_complete_on_eof= FALSE
1141
- ,.http_major= 1
1142
- ,.http_minor= 1
1143
- ,.method= HTTP_UNLINK
1144
- ,.request_path= "/images/my_dog.jpg"
1145
- ,.request_url= "/images/my_dog.jpg"
1146
- ,.query_string= ""
1147
- ,.fragment= ""
1148
- ,.num_headers= 2
1149
- ,.headers= { { "Host", "example.com" }
1150
- , { "Link", "<http://example.com/profiles/sally>; rel=\"tag\"" }
1151
- }
1152
- ,.body= ""
1153
- }
1154
-
1155
- #define SOURCE_REQUEST 42
1156
- , {.name = "source request"
1157
- ,.type= HTTP_REQUEST
1158
- ,.raw= "SOURCE /music/sweet/music HTTP/1.1\r\n"
1159
- "Host: example.com\r\n"
1160
- "\r\n"
1161
- ,.should_keep_alive= TRUE
1162
- ,.message_complete_on_eof= FALSE
1163
- ,.http_major= 1
1164
- ,.http_minor= 1
1165
- ,.method= HTTP_SOURCE
1166
- ,.request_path= "/music/sweet/music"
1167
- ,.request_url= "/music/sweet/music"
1168
- ,.query_string= ""
1169
- ,.fragment= ""
1170
- ,.num_headers= 1
1171
- ,.headers= { { "Host", "example.com" } }
1172
- ,.body= ""
1173
- }
1174
-
1175
- #define SOURCE_ICE_REQUEST 43
1176
- , {.name = "source request"
1177
- ,.type= HTTP_REQUEST
1178
- ,.raw= "SOURCE /music/sweet/music ICE/1.0\r\n"
1179
- "Host: example.com\r\n"
1180
- "\r\n"
1181
- ,.should_keep_alive= FALSE
1182
- ,.message_complete_on_eof= FALSE
1183
- ,.http_major= 1
1184
- ,.http_minor= 0
1185
- ,.method= HTTP_SOURCE
1186
- ,.request_path= "/music/sweet/music"
1187
- ,.request_url= "/music/sweet/music"
1188
- ,.query_string= ""
1189
- ,.fragment= ""
1190
- ,.num_headers= 1
1191
- ,.headers= { { "Host", "example.com" } }
1192
- ,.body= ""
1193
- }
1194
-
1195
- #define POST_MULTI_TE_LAST_CHUNKED 44
1196
- , {.name= "post - multi coding transfer-encoding chunked body"
1197
- ,.type= HTTP_REQUEST
1198
- ,.raw= "POST / HTTP/1.1\r\n"
1199
- "Transfer-Encoding: deflate, chunked\r\n"
1200
- "\r\n"
1201
- "1e\r\nall your base are belong to us\r\n"
1202
- "0\r\n"
1203
- "\r\n"
1204
- ,.should_keep_alive= TRUE
1205
- ,.message_complete_on_eof= FALSE
1206
- ,.http_major= 1
1207
- ,.http_minor= 1
1208
- ,.method= HTTP_POST
1209
- ,.query_string= ""
1210
- ,.fragment= ""
1211
- ,.request_path= "/"
1212
- ,.request_url= "/"
1213
- ,.num_headers= 1
1214
- ,.headers=
1215
- { { "Transfer-Encoding" , "deflate, chunked" }
1216
- }
1217
- ,.body= "all your base are belong to us"
1218
- ,.num_chunks_complete= 2
1219
- ,.chunk_lengths= { 0x1e }
1220
- }
1221
-
1222
- #define POST_MULTI_LINE_TE_LAST_CHUNKED 45
1223
- , {.name= "post - multi line coding transfer-encoding chunked body"
1224
- ,.type= HTTP_REQUEST
1225
- ,.raw= "POST / HTTP/1.1\r\n"
1226
- "Transfer-Encoding: deflate,\r\n"
1227
- " chunked\r\n"
1228
- "\r\n"
1229
- "1e\r\nall your base are belong to us\r\n"
1230
- "0\r\n"
1231
- "\r\n"
1232
- ,.should_keep_alive= TRUE
1233
- ,.message_complete_on_eof= FALSE
1234
- ,.http_major= 1
1235
- ,.http_minor= 1
1236
- ,.method= HTTP_POST
1237
- ,.query_string= ""
1238
- ,.fragment= ""
1239
- ,.request_path= "/"
1240
- ,.request_url= "/"
1241
- ,.num_headers= 1
1242
- ,.headers=
1243
- { { "Transfer-Encoding" , "deflate, chunked" }
1244
- }
1245
- ,.body= "all your base are belong to us"
1246
- ,.num_chunks_complete= 2
1247
- ,.chunk_lengths= { 0x1e }
1248
- }
1249
- };
1250
-
1251
- /* * R E S P O N S E S * */
1252
- const struct message responses[] =
1253
- #define GOOGLE_301 0
1254
- { {.name= "google 301"
1255
- ,.type= HTTP_RESPONSE
1256
- ,.raw= "HTTP/1.1 301 Moved Permanently\r\n"
1257
- "Location: http://www.google.com/\r\n"
1258
- "Content-Type: text/html; charset=UTF-8\r\n"
1259
- "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n"
1260
- "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n"
1261
- "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */
1262
- "Cache-Control: public, max-age=2592000\r\n"
1263
- "Server: gws\r\n"
1264
- "Content-Length: 219 \r\n"
1265
- "\r\n"
1266
- "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n"
1267
- "<TITLE>301 Moved</TITLE></HEAD><BODY>\n"
1268
- "<H1>301 Moved</H1>\n"
1269
- "The document has moved\n"
1270
- "<A HREF=\"http://www.google.com/\">here</A>.\r\n"
1271
- "</BODY></HTML>\r\n"
1272
- ,.should_keep_alive= TRUE
1273
- ,.message_complete_on_eof= FALSE
1274
- ,.http_major= 1
1275
- ,.http_minor= 1
1276
- ,.status_code= 301
1277
- ,.response_status= "Moved Permanently"
1278
- ,.num_headers= 8
1279
- ,.headers=
1280
- { { "Location", "http://www.google.com/" }
1281
- , { "Content-Type", "text/html; charset=UTF-8" }
1282
- , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" }
1283
- , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" }
1284
- , { "X-$PrototypeBI-Version", "1.6.0.3" }
1285
- , { "Cache-Control", "public, max-age=2592000" }
1286
- , { "Server", "gws" }
1287
- , { "Content-Length", "219 " }
1288
- }
1289
- ,.body= "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n"
1290
- "<TITLE>301 Moved</TITLE></HEAD><BODY>\n"
1291
- "<H1>301 Moved</H1>\n"
1292
- "The document has moved\n"
1293
- "<A HREF=\"http://www.google.com/\">here</A>.\r\n"
1294
- "</BODY></HTML>\r\n"
1295
- }
1296
-
1297
- #define NO_CONTENT_LENGTH_RESPONSE 1
1298
- /* The client should wait for the server's EOF. That is, when content-length
1299
- * is not specified, and "Connection: close", the end of body is specified
1300
- * by the EOF.
1301
- * Compare with APACHEBENCH_GET
1302
- */
1303
- , {.name= "no content-length response"
1304
- ,.type= HTTP_RESPONSE
1305
- ,.raw= "HTTP/1.1 200 OK\r\n"
1306
- "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n"
1307
- "Server: Apache\r\n"
1308
- "X-Powered-By: Servlet/2.5 JSP/2.1\r\n"
1309
- "Content-Type: text/xml; charset=utf-8\r\n"
1310
- "Connection: close\r\n"
1311
- "\r\n"
1312
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1313
- "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
1314
- " <SOAP-ENV:Body>\n"
1315
- " <SOAP-ENV:Fault>\n"
1316
- " <faultcode>SOAP-ENV:Client</faultcode>\n"
1317
- " <faultstring>Client Error</faultstring>\n"
1318
- " </SOAP-ENV:Fault>\n"
1319
- " </SOAP-ENV:Body>\n"
1320
- "</SOAP-ENV:Envelope>"
1321
- ,.should_keep_alive= FALSE
1322
- ,.message_complete_on_eof= TRUE
1323
- ,.http_major= 1
1324
- ,.http_minor= 1
1325
- ,.status_code= 200
1326
- ,.response_status= "OK"
1327
- ,.num_headers= 5
1328
- ,.headers=
1329
- { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" }
1330
- , { "Server", "Apache" }
1331
- , { "X-Powered-By", "Servlet/2.5 JSP/2.1" }
1332
- , { "Content-Type", "text/xml; charset=utf-8" }
1333
- , { "Connection", "close" }
1334
- }
1335
- ,.body= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1336
- "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
1337
- " <SOAP-ENV:Body>\n"
1338
- " <SOAP-ENV:Fault>\n"
1339
- " <faultcode>SOAP-ENV:Client</faultcode>\n"
1340
- " <faultstring>Client Error</faultstring>\n"
1341
- " </SOAP-ENV:Fault>\n"
1342
- " </SOAP-ENV:Body>\n"
1343
- "</SOAP-ENV:Envelope>"
1344
- }
1345
-
1346
- #define NO_HEADERS_NO_BODY_404 2
1347
- , {.name= "404 no headers no body"
1348
- ,.type= HTTP_RESPONSE
1349
- ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n"
1350
- ,.should_keep_alive= FALSE
1351
- ,.message_complete_on_eof= TRUE
1352
- ,.http_major= 1
1353
- ,.http_minor= 1
1354
- ,.status_code= 404
1355
- ,.response_status= "Not Found"
1356
- ,.num_headers= 0
1357
- ,.headers= {}
1358
- ,.body_size= 0
1359
- ,.body= ""
1360
- }
1361
-
1362
- #define NO_REASON_PHRASE 3
1363
- , {.name= "301 no response phrase"
1364
- ,.type= HTTP_RESPONSE
1365
- ,.raw= "HTTP/1.1 301\r\n\r\n"
1366
- ,.should_keep_alive = FALSE
1367
- ,.message_complete_on_eof= TRUE
1368
- ,.http_major= 1
1369
- ,.http_minor= 1
1370
- ,.status_code= 301
1371
- ,.response_status= ""
1372
- ,.num_headers= 0
1373
- ,.headers= {}
1374
- ,.body= ""
1375
- }
1376
-
1377
- #define TRAILING_SPACE_ON_CHUNKED_BODY 4
1378
- , {.name="200 trailing space on chunked body"
1379
- ,.type= HTTP_RESPONSE
1380
- ,.raw= "HTTP/1.1 200 OK\r\n"
1381
- "Content-Type: text/plain\r\n"
1382
- "Transfer-Encoding: chunked\r\n"
1383
- "\r\n"
1384
- "25 \r\n"
1385
- "This is the data in the first chunk\r\n"
1386
- "\r\n"
1387
- "1C\r\n"
1388
- "and this is the second one\r\n"
1389
- "\r\n"
1390
- "0 \r\n"
1391
- "\r\n"
1392
- ,.should_keep_alive= TRUE
1393
- ,.message_complete_on_eof= FALSE
1394
- ,.http_major= 1
1395
- ,.http_minor= 1
1396
- ,.status_code= 200
1397
- ,.response_status= "OK"
1398
- ,.num_headers= 2
1399
- ,.headers=
1400
- { {"Content-Type", "text/plain" }
1401
- , {"Transfer-Encoding", "chunked" }
1402
- }
1403
- ,.body_size = 37+28
1404
- ,.body =
1405
- "This is the data in the first chunk\r\n"
1406
- "and this is the second one\r\n"
1407
- ,.num_chunks_complete= 3
1408
- ,.chunk_lengths= { 0x25, 0x1c }
1409
- }
1410
-
1411
- #define NO_CARRIAGE_RET 5
1412
- , {.name="no carriage ret"
1413
- ,.type= HTTP_RESPONSE
1414
- ,.raw= "HTTP/1.1 200 OK\n"
1415
- "Content-Type: text/html; charset=utf-8\n"
1416
- "Connection: close\n"
1417
- "\n"
1418
- "these headers are from http://news.ycombinator.com/"
1419
- ,.should_keep_alive= FALSE
1420
- ,.message_complete_on_eof= TRUE
1421
- ,.http_major= 1
1422
- ,.http_minor= 1
1423
- ,.status_code= 200
1424
- ,.response_status= "OK"
1425
- ,.num_headers= 2
1426
- ,.headers=
1427
- { {"Content-Type", "text/html; charset=utf-8" }
1428
- , {"Connection", "close" }
1429
- }
1430
- ,.body= "these headers are from http://news.ycombinator.com/"
1431
- }
1432
-
1433
- #define PROXY_CONNECTION 6
1434
- , {.name="proxy connection"
1435
- ,.type= HTTP_RESPONSE
1436
- ,.raw= "HTTP/1.1 200 OK\r\n"
1437
- "Content-Type: text/html; charset=UTF-8\r\n"
1438
- "Content-Length: 11\r\n"
1439
- "Proxy-Connection: close\r\n"
1440
- "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n"
1441
- "\r\n"
1442
- "hello world"
1443
- ,.should_keep_alive= FALSE
1444
- ,.message_complete_on_eof= FALSE
1445
- ,.http_major= 1
1446
- ,.http_minor= 1
1447
- ,.status_code= 200
1448
- ,.response_status= "OK"
1449
- ,.num_headers= 4
1450
- ,.headers=
1451
- { {"Content-Type", "text/html; charset=UTF-8" }
1452
- , {"Content-Length", "11" }
1453
- , {"Proxy-Connection", "close" }
1454
- , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"}
1455
- }
1456
- ,.body= "hello world"
1457
- }
1458
-
1459
- #define UNDERSTORE_HEADER_KEY 7
1460
- // shown by
1461
- // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;"
1462
- , {.name="underscore header key"
1463
- ,.type= HTTP_RESPONSE
1464
- ,.raw= "HTTP/1.1 200 OK\r\n"
1465
- "Server: DCLK-AdSvr\r\n"
1466
- "Content-Type: text/xml\r\n"
1467
- "Content-Length: 0\r\n"
1468
- "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n"
1469
- ,.should_keep_alive= TRUE
1470
- ,.message_complete_on_eof= FALSE
1471
- ,.http_major= 1
1472
- ,.http_minor= 1
1473
- ,.status_code= 200
1474
- ,.response_status= "OK"
1475
- ,.num_headers= 4
1476
- ,.headers=
1477
- { {"Server", "DCLK-AdSvr" }
1478
- , {"Content-Type", "text/xml" }
1479
- , {"Content-Length", "0" }
1480
- , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" }
1481
- }
1482
- ,.body= ""
1483
- }
1484
-
1485
- #define BONJOUR_MADAME_FR 8
1486
- /* The client should not merge two headers fields when the first one doesn't
1487
- * have a value.
1488
- */
1489
- , {.name= "bonjourmadame.fr"
1490
- ,.type= HTTP_RESPONSE
1491
- ,.raw= "HTTP/1.0 301 Moved Permanently\r\n"
1492
- "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n"
1493
- "Server: Apache/2.2.3 (Red Hat)\r\n"
1494
- "Cache-Control: public\r\n"
1495
- "Pragma: \r\n"
1496
- "Location: http://www.bonjourmadame.fr/\r\n"
1497
- "Vary: Accept-Encoding\r\n"
1498
- "Content-Length: 0\r\n"
1499
- "Content-Type: text/html; charset=UTF-8\r\n"
1500
- "Connection: keep-alive\r\n"
1501
- "\r\n"
1502
- ,.should_keep_alive= TRUE
1503
- ,.message_complete_on_eof= FALSE
1504
- ,.http_major= 1
1505
- ,.http_minor= 0
1506
- ,.status_code= 301
1507
- ,.response_status= "Moved Permanently"
1508
- ,.num_headers= 9
1509
- ,.headers=
1510
- { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" }
1511
- , { "Server", "Apache/2.2.3 (Red Hat)" }
1512
- , { "Cache-Control", "public" }
1513
- , { "Pragma", "" }
1514
- , { "Location", "http://www.bonjourmadame.fr/" }
1515
- , { "Vary", "Accept-Encoding" }
1516
- , { "Content-Length", "0" }
1517
- , { "Content-Type", "text/html; charset=UTF-8" }
1518
- , { "Connection", "keep-alive" }
1519
- }
1520
- ,.body= ""
1521
- }
1522
-
1523
- #define RES_FIELD_UNDERSCORE 9
1524
- /* Should handle spaces in header fields */
1525
- , {.name= "field underscore"
1526
- ,.type= HTTP_RESPONSE
1527
- ,.raw= "HTTP/1.1 200 OK\r\n"
1528
- "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n"
1529
- "Server: Apache\r\n"
1530
- "Cache-Control: no-cache, must-revalidate\r\n"
1531
- "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n"
1532
- ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n"
1533
- "Vary: Accept-Encoding\r\n"
1534
- "_eep-Alive: timeout=45\r\n" /* semantic value ignored */
1535
- "_onnection: Keep-Alive\r\n" /* semantic value ignored */
1536
- "Transfer-Encoding: chunked\r\n"
1537
- "Content-Type: text/html\r\n"
1538
- "Connection: close\r\n"
1539
- "\r\n"
1540
- "0\r\n\r\n"
1541
- ,.should_keep_alive= FALSE
1542
- ,.message_complete_on_eof= FALSE
1543
- ,.http_major= 1
1544
- ,.http_minor= 1
1545
- ,.status_code= 200
1546
- ,.response_status= "OK"
1547
- ,.num_headers= 11
1548
- ,.headers=
1549
- { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" }
1550
- , { "Server", "Apache" }
1551
- , { "Cache-Control", "no-cache, must-revalidate" }
1552
- , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" }
1553
- , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" }
1554
- , { "Vary", "Accept-Encoding" }
1555
- , { "_eep-Alive", "timeout=45" }
1556
- , { "_onnection", "Keep-Alive" }
1557
- , { "Transfer-Encoding", "chunked" }
1558
- , { "Content-Type", "text/html" }
1559
- , { "Connection", "close" }
1560
- }
1561
- ,.body= ""
1562
- ,.num_chunks_complete= 1
1563
- ,.chunk_lengths= {}
1564
- }
1565
-
1566
- #define NON_ASCII_IN_STATUS_LINE 10
1567
- /* Should handle non-ASCII in status line */
1568
- , {.name= "non-ASCII in status line"
1569
- ,.type= HTTP_RESPONSE
1570
- ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n"
1571
- "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n"
1572
- "Content-Length: 0\r\n"
1573
- "Connection: close\r\n"
1574
- "\r\n"
1575
- ,.should_keep_alive= FALSE
1576
- ,.message_complete_on_eof= FALSE
1577
- ,.http_major= 1
1578
- ,.http_minor= 1
1579
- ,.status_code= 500
1580
- ,.response_status= "Oriëntatieprobleem"
1581
- ,.num_headers= 3
1582
- ,.headers=
1583
- { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" }
1584
- , { "Content-Length", "0" }
1585
- , { "Connection", "close" }
1586
- }
1587
- ,.body= ""
1588
- }
1589
-
1590
- #define HTTP_VERSION_0_9 11
1591
- /* Should handle HTTP/0.9 */
1592
- , {.name= "http version 0.9"
1593
- ,.type= HTTP_RESPONSE
1594
- ,.raw= "HTTP/0.9 200 OK\r\n"
1595
- "\r\n"
1596
- ,.should_keep_alive= FALSE
1597
- ,.message_complete_on_eof= TRUE
1598
- ,.http_major= 0
1599
- ,.http_minor= 9
1600
- ,.status_code= 200
1601
- ,.response_status= "OK"
1602
- ,.num_headers= 0
1603
- ,.headers=
1604
- {}
1605
- ,.body= ""
1606
- }
1607
-
1608
- #define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12
1609
- /* The client should wait for the server's EOF. That is, when neither
1610
- * content-length nor transfer-encoding is specified, the end of body
1611
- * is specified by the EOF.
1612
- */
1613
- , {.name= "neither content-length nor transfer-encoding response"
1614
- ,.type= HTTP_RESPONSE
1615
- ,.raw= "HTTP/1.1 200 OK\r\n"
1616
- "Content-Type: text/plain\r\n"
1617
- "\r\n"
1618
- "hello world"
1619
- ,.should_keep_alive= FALSE
1620
- ,.message_complete_on_eof= TRUE
1621
- ,.http_major= 1
1622
- ,.http_minor= 1
1623
- ,.status_code= 200
1624
- ,.response_status= "OK"
1625
- ,.num_headers= 1
1626
- ,.headers=
1627
- { { "Content-Type", "text/plain" }
1628
- }
1629
- ,.body= "hello world"
1630
- }
1631
-
1632
- #define NO_BODY_HTTP10_KA_200 13
1633
- , {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status"
1634
- ,.type= HTTP_RESPONSE
1635
- ,.raw= "HTTP/1.0 200 OK\r\n"
1636
- "Connection: keep-alive\r\n"
1637
- "\r\n"
1638
- ,.should_keep_alive= FALSE
1639
- ,.message_complete_on_eof= TRUE
1640
- ,.http_major= 1
1641
- ,.http_minor= 0
1642
- ,.status_code= 200
1643
- ,.response_status= "OK"
1644
- ,.num_headers= 1
1645
- ,.headers=
1646
- { { "Connection", "keep-alive" }
1647
- }
1648
- ,.body_size= 0
1649
- ,.body= ""
1650
- }
1651
-
1652
- #define NO_BODY_HTTP10_KA_204 14
1653
- , {.name= "HTTP/1.0 with keep-alive and a 204 status"
1654
- ,.type= HTTP_RESPONSE
1655
- ,.raw= "HTTP/1.0 204 No content\r\n"
1656
- "Connection: keep-alive\r\n"
1657
- "\r\n"
1658
- ,.should_keep_alive= TRUE
1659
- ,.message_complete_on_eof= FALSE
1660
- ,.http_major= 1
1661
- ,.http_minor= 0
1662
- ,.status_code= 204
1663
- ,.response_status= "No content"
1664
- ,.num_headers= 1
1665
- ,.headers=
1666
- { { "Connection", "keep-alive" }
1667
- }
1668
- ,.body_size= 0
1669
- ,.body= ""
1670
- }
1671
-
1672
- #define NO_BODY_HTTP11_KA_200 15
1673
- , {.name= "HTTP/1.1 with an EOF-terminated 200 status"
1674
- ,.type= HTTP_RESPONSE
1675
- ,.raw= "HTTP/1.1 200 OK\r\n"
1676
- "\r\n"
1677
- ,.should_keep_alive= FALSE
1678
- ,.message_complete_on_eof= TRUE
1679
- ,.http_major= 1
1680
- ,.http_minor= 1
1681
- ,.status_code= 200
1682
- ,.response_status= "OK"
1683
- ,.num_headers= 0
1684
- ,.headers={}
1685
- ,.body_size= 0
1686
- ,.body= ""
1687
- }
1688
-
1689
- #define NO_BODY_HTTP11_KA_204 16
1690
- , {.name= "HTTP/1.1 with a 204 status"
1691
- ,.type= HTTP_RESPONSE
1692
- ,.raw= "HTTP/1.1 204 No content\r\n"
1693
- "\r\n"
1694
- ,.should_keep_alive= TRUE
1695
- ,.message_complete_on_eof= FALSE
1696
- ,.http_major= 1
1697
- ,.http_minor= 1
1698
- ,.status_code= 204
1699
- ,.response_status= "No content"
1700
- ,.num_headers= 0
1701
- ,.headers={}
1702
- ,.body_size= 0
1703
- ,.body= ""
1704
- }
1705
-
1706
- #define NO_BODY_HTTP11_NOKA_204 17
1707
- , {.name= "HTTP/1.1 with a 204 status and keep-alive disabled"
1708
- ,.type= HTTP_RESPONSE
1709
- ,.raw= "HTTP/1.1 204 No content\r\n"
1710
- "Connection: close\r\n"
1711
- "\r\n"
1712
- ,.should_keep_alive= FALSE
1713
- ,.message_complete_on_eof= FALSE
1714
- ,.http_major= 1
1715
- ,.http_minor= 1
1716
- ,.status_code= 204
1717
- ,.response_status= "No content"
1718
- ,.num_headers= 1
1719
- ,.headers=
1720
- { { "Connection", "close" }
1721
- }
1722
- ,.body_size= 0
1723
- ,.body= ""
1724
- }
1725
-
1726
- #define NO_BODY_HTTP11_KA_CHUNKED_200 18
1727
- , {.name= "HTTP/1.1 with chunked endocing and a 200 response"
1728
- ,.type= HTTP_RESPONSE
1729
- ,.raw= "HTTP/1.1 200 OK\r\n"
1730
- "Transfer-Encoding: chunked\r\n"
1731
- "\r\n"
1732
- "0\r\n"
1733
- "\r\n"
1734
- ,.should_keep_alive= TRUE
1735
- ,.message_complete_on_eof= FALSE
1736
- ,.http_major= 1
1737
- ,.http_minor= 1
1738
- ,.status_code= 200
1739
- ,.response_status= "OK"
1740
- ,.num_headers= 1
1741
- ,.headers=
1742
- { { "Transfer-Encoding", "chunked" }
1743
- }
1744
- ,.body_size= 0
1745
- ,.body= ""
1746
- ,.num_chunks_complete= 1
1747
- }
1748
-
1749
- #if !HTTP_PARSER_STRICT
1750
- #define SPACE_IN_FIELD_RES 19
1751
- /* Should handle spaces in header fields */
1752
- , {.name= "field space"
1753
- ,.type= HTTP_RESPONSE
1754
- ,.raw= "HTTP/1.1 200 OK\r\n"
1755
- "Server: Microsoft-IIS/6.0\r\n"
1756
- "X-Powered-By: ASP.NET\r\n"
1757
- "en-US Content-Type: text/xml\r\n" /* this is the problem */
1758
- "Content-Type: text/xml\r\n"
1759
- "Content-Length: 16\r\n"
1760
- "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n"
1761
- "Connection: keep-alive\r\n"
1762
- "\r\n"
1763
- "<xml>hello</xml>" /* fake body */
1764
- ,.should_keep_alive= TRUE
1765
- ,.message_complete_on_eof= FALSE
1766
- ,.http_major= 1
1767
- ,.http_minor= 1
1768
- ,.status_code= 200
1769
- ,.response_status= "OK"
1770
- ,.num_headers= 7
1771
- ,.headers=
1772
- { { "Server", "Microsoft-IIS/6.0" }
1773
- , { "X-Powered-By", "ASP.NET" }
1774
- , { "en-US Content-Type", "text/xml" }
1775
- , { "Content-Type", "text/xml" }
1776
- , { "Content-Length", "16" }
1777
- , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" }
1778
- , { "Connection", "keep-alive" }
1779
- }
1780
- ,.body= "<xml>hello</xml>"
1781
- }
1782
- #endif /* !HTTP_PARSER_STRICT */
1783
-
1784
- #define AMAZON_COM 20
1785
- , {.name= "amazon.com"
1786
- ,.type= HTTP_RESPONSE
1787
- ,.raw= "HTTP/1.1 301 MovedPermanently\r\n"
1788
- "Date: Wed, 15 May 2013 17:06:33 GMT\r\n"
1789
- "Server: Server\r\n"
1790
- "x-amz-id-1: 0GPHKXSJQ826RK7GZEB2\r\n"
1791
- "p3p: policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"\r\n"
1792
- "x-amz-id-2: STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD\r\n"
1793
- "Location: http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846\r\n"
1794
- "Vary: Accept-Encoding,User-Agent\r\n"
1795
- "Content-Type: text/html; charset=ISO-8859-1\r\n"
1796
- "Transfer-Encoding: chunked\r\n"
1797
- "\r\n"
1798
- "1\r\n"
1799
- "\n\r\n"
1800
- "0\r\n"
1801
- "\r\n"
1802
- ,.should_keep_alive= TRUE
1803
- ,.message_complete_on_eof= FALSE
1804
- ,.http_major= 1
1805
- ,.http_minor= 1
1806
- ,.status_code= 301
1807
- ,.response_status= "MovedPermanently"
1808
- ,.num_headers= 9
1809
- ,.headers= { { "Date", "Wed, 15 May 2013 17:06:33 GMT" }
1810
- , { "Server", "Server" }
1811
- , { "x-amz-id-1", "0GPHKXSJQ826RK7GZEB2" }
1812
- , { "p3p", "policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"" }
1813
- , { "x-amz-id-2", "STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD" }
1814
- , { "Location", "http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846" }
1815
- , { "Vary", "Accept-Encoding,User-Agent" }
1816
- , { "Content-Type", "text/html; charset=ISO-8859-1" }
1817
- , { "Transfer-Encoding", "chunked" }
1818
- }
1819
- ,.body= "\n"
1820
- ,.num_chunks_complete= 2
1821
- ,.chunk_lengths= { 1 }
1822
- }
1823
-
1824
- #define EMPTY_REASON_PHRASE_AFTER_SPACE 21
1825
- , {.name= "empty reason phrase after space"
1826
- ,.type= HTTP_RESPONSE
1827
- ,.raw= "HTTP/1.1 200 \r\n"
1828
- "\r\n"
1829
- ,.should_keep_alive= FALSE
1830
- ,.message_complete_on_eof= TRUE
1831
- ,.http_major= 1
1832
- ,.http_minor= 1
1833
- ,.status_code= 200
1834
- ,.response_status= ""
1835
- ,.num_headers= 0
1836
- ,.headers= {}
1837
- ,.body= ""
1838
- }
1839
-
1840
- #define CONTENT_LENGTH_X 22
1841
- , {.name= "Content-Length-X"
1842
- ,.type= HTTP_RESPONSE
1843
- ,.raw= "HTTP/1.1 200 OK\r\n"
1844
- "Content-Length-X: 0\r\n"
1845
- "Transfer-Encoding: chunked\r\n"
1846
- "\r\n"
1847
- "2\r\n"
1848
- "OK\r\n"
1849
- "0\r\n"
1850
- "\r\n"
1851
- ,.should_keep_alive= TRUE
1852
- ,.message_complete_on_eof= FALSE
1853
- ,.http_major= 1
1854
- ,.http_minor= 1
1855
- ,.status_code= 200
1856
- ,.response_status= "OK"
1857
- ,.num_headers= 2
1858
- ,.headers= { { "Content-Length-X", "0" }
1859
- , { "Transfer-Encoding", "chunked" }
1860
- }
1861
- ,.body= "OK"
1862
- ,.num_chunks_complete= 2
1863
- ,.chunk_lengths= { 2 }
1864
- }
1865
-
1866
- #define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER 23
1867
- , {.name= "HTTP 101 response with Upgrade header"
1868
- ,.type= HTTP_RESPONSE
1869
- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n"
1870
- "Connection: upgrade\r\n"
1871
- "Upgrade: h2c\r\n"
1872
- "\r\n"
1873
- "proto"
1874
- ,.should_keep_alive= TRUE
1875
- ,.message_complete_on_eof= FALSE
1876
- ,.http_major= 1
1877
- ,.http_minor= 1
1878
- ,.status_code= 101
1879
- ,.response_status= "Switching Protocols"
1880
- ,.upgrade= "proto"
1881
- ,.num_headers= 2
1882
- ,.headers=
1883
- { { "Connection", "upgrade" }
1884
- , { "Upgrade", "h2c" }
1885
- }
1886
- }
1887
-
1888
- #define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 24
1889
- , {.name= "HTTP 101 response with Upgrade and Content-Length header"
1890
- ,.type= HTTP_RESPONSE
1891
- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n"
1892
- "Connection: upgrade\r\n"
1893
- "Upgrade: h2c\r\n"
1894
- "Content-Length: 4\r\n"
1895
- "\r\n"
1896
- "body"
1897
- "proto"
1898
- ,.should_keep_alive= TRUE
1899
- ,.message_complete_on_eof= FALSE
1900
- ,.http_major= 1
1901
- ,.http_minor= 1
1902
- ,.status_code= 101
1903
- ,.response_status= "Switching Protocols"
1904
- ,.body= "body"
1905
- ,.upgrade= "proto"
1906
- ,.num_headers= 3
1907
- ,.headers=
1908
- { { "Connection", "upgrade" }
1909
- , { "Upgrade", "h2c" }
1910
- , { "Content-Length", "4" }
1911
- }
1912
- }
1913
-
1914
- #define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 25
1915
- , {.name= "HTTP 101 response with Upgrade and Transfer-Encoding header"
1916
- ,.type= HTTP_RESPONSE
1917
- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n"
1918
- "Connection: upgrade\r\n"
1919
- "Upgrade: h2c\r\n"
1920
- "Transfer-Encoding: chunked\r\n"
1921
- "\r\n"
1922
- "2\r\n"
1923
- "bo\r\n"
1924
- "2\r\n"
1925
- "dy\r\n"
1926
- "0\r\n"
1927
- "\r\n"
1928
- "proto"
1929
- ,.should_keep_alive= TRUE
1930
- ,.message_complete_on_eof= FALSE
1931
- ,.http_major= 1
1932
- ,.http_minor= 1
1933
- ,.status_code= 101
1934
- ,.response_status= "Switching Protocols"
1935
- ,.body= "body"
1936
- ,.upgrade= "proto"
1937
- ,.num_headers= 3
1938
- ,.headers=
1939
- { { "Connection", "upgrade" }
1940
- , { "Upgrade", "h2c" }
1941
- , { "Transfer-Encoding", "chunked" }
1942
- }
1943
- ,.num_chunks_complete= 3
1944
- ,.chunk_lengths= { 2, 2 }
1945
- }
1946
-
1947
- #define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER 26
1948
- , {.name= "HTTP 200 response with Upgrade header"
1949
- ,.type= HTTP_RESPONSE
1950
- ,.raw= "HTTP/1.1 200 OK\r\n"
1951
- "Connection: upgrade\r\n"
1952
- "Upgrade: h2c\r\n"
1953
- "\r\n"
1954
- "body"
1955
- ,.should_keep_alive= FALSE
1956
- ,.message_complete_on_eof= TRUE
1957
- ,.http_major= 1
1958
- ,.http_minor= 1
1959
- ,.status_code= 200
1960
- ,.response_status= "OK"
1961
- ,.body= "body"
1962
- ,.upgrade= NULL
1963
- ,.num_headers= 2
1964
- ,.headers=
1965
- { { "Connection", "upgrade" }
1966
- , { "Upgrade", "h2c" }
1967
- }
1968
- }
1969
-
1970
- #define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 27
1971
- , {.name= "HTTP 200 response with Upgrade and Content-Length header"
1972
- ,.type= HTTP_RESPONSE
1973
- ,.raw= "HTTP/1.1 200 OK\r\n"
1974
- "Connection: upgrade\r\n"
1975
- "Upgrade: h2c\r\n"
1976
- "Content-Length: 4\r\n"
1977
- "\r\n"
1978
- "body"
1979
- ,.should_keep_alive= TRUE
1980
- ,.message_complete_on_eof= FALSE
1981
- ,.http_major= 1
1982
- ,.http_minor= 1
1983
- ,.status_code= 200
1984
- ,.response_status= "OK"
1985
- ,.num_headers= 3
1986
- ,.body= "body"
1987
- ,.upgrade= NULL
1988
- ,.headers=
1989
- { { "Connection", "upgrade" }
1990
- , { "Upgrade", "h2c" }
1991
- , { "Content-Length", "4" }
1992
- }
1993
- }
1994
-
1995
- #define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 28
1996
- , {.name= "HTTP 200 response with Upgrade and Transfer-Encoding header"
1997
- ,.type= HTTP_RESPONSE
1998
- ,.raw= "HTTP/1.1 200 OK\r\n"
1999
- "Connection: upgrade\r\n"
2000
- "Upgrade: h2c\r\n"
2001
- "Transfer-Encoding: chunked\r\n"
2002
- "\r\n"
2003
- "2\r\n"
2004
- "bo\r\n"
2005
- "2\r\n"
2006
- "dy\r\n"
2007
- "0\r\n"
2008
- "\r\n"
2009
- ,.should_keep_alive= TRUE
2010
- ,.message_complete_on_eof= FALSE
2011
- ,.http_major= 1
2012
- ,.http_minor= 1
2013
- ,.status_code= 200
2014
- ,.response_status= "OK"
2015
- ,.num_headers= 3
2016
- ,.body= "body"
2017
- ,.upgrade= NULL
2018
- ,.headers=
2019
- { { "Connection", "upgrade" }
2020
- , { "Upgrade", "h2c" }
2021
- , { "Transfer-Encoding", "chunked" }
2022
- }
2023
- ,.num_chunks_complete= 3
2024
- ,.chunk_lengths= { 2, 2 }
2025
- }
2026
- #define HTTP_200_MULTI_TE_NOT_LAST_CHUNKED 29
2027
- , {.name= "HTTP 200 response with `chunked` being *not last* Transfer-Encoding"
2028
- ,.type= HTTP_RESPONSE
2029
- ,.raw= "HTTP/1.1 200 OK\r\n"
2030
- "Transfer-Encoding: chunked, identity\r\n"
2031
- "\r\n"
2032
- "2\r\n"
2033
- "OK\r\n"
2034
- "0\r\n"
2035
- "\r\n"
2036
- ,.should_keep_alive= FALSE
2037
- ,.message_complete_on_eof= TRUE
2038
- ,.http_major= 1
2039
- ,.http_minor= 1
2040
- ,.status_code= 200
2041
- ,.response_status= "OK"
2042
- ,.num_headers= 1
2043
- ,.headers= { { "Transfer-Encoding", "chunked, identity" }
2044
- }
2045
- ,.body= "2\r\nOK\r\n0\r\n\r\n"
2046
- ,.num_chunks_complete= 0
2047
- }
2048
- };
2049
-
2050
- /* strnlen() is a POSIX.2008 addition. Can't rely on it being available so
2051
- * define it ourselves.
2052
- */
2053
- size_t
2054
- strnlen(const char *s, size_t maxlen)
2055
- {
2056
- const char *p;
2057
-
2058
- p = memchr(s, '\0', maxlen);
2059
- if (p == NULL)
2060
- return maxlen;
2061
-
2062
- return p - s;
2063
- }
2064
-
2065
- size_t
2066
- strlncat(char *dst, size_t len, const char *src, size_t n)
2067
- {
2068
- size_t slen;
2069
- size_t dlen;
2070
- size_t rlen;
2071
- size_t ncpy;
2072
-
2073
- slen = strnlen(src, n);
2074
- dlen = strnlen(dst, len);
2075
-
2076
- if (dlen < len) {
2077
- rlen = len - dlen;
2078
- ncpy = slen < rlen ? slen : (rlen - 1);
2079
- memcpy(dst + dlen, src, ncpy);
2080
- dst[dlen + ncpy] = '\0';
2081
- }
2082
-
2083
- assert(len > slen + dlen);
2084
- return slen + dlen;
2085
- }
2086
-
2087
- size_t
2088
- strlncpy(char *dst, size_t len, const char *src, size_t n)
2089
- {
2090
- size_t slen;
2091
- size_t ncpy;
2092
-
2093
- slen = strnlen(src, n);
2094
-
2095
- if (len > 0) {
2096
- ncpy = slen < len ? slen : (len - 1);
2097
- memcpy(dst, src, ncpy);
2098
- dst[ncpy] = '\0';
2099
- }
2100
-
2101
- assert(len > slen);
2102
- return slen;
2103
- }
2104
-
2105
- int
2106
- request_url_cb (http_parser *p, const char *buf, size_t len)
2107
- {
2108
- assert(p == &parser);
2109
- strlncat(messages[num_messages].request_url,
2110
- sizeof(messages[num_messages].request_url),
2111
- buf,
2112
- len);
2113
- return 0;
2114
- }
2115
-
2116
- int
2117
- header_field_cb (http_parser *p, const char *buf, size_t len)
2118
- {
2119
- assert(p == &parser);
2120
- struct message *m = &messages[num_messages];
2121
-
2122
- if (m->last_header_element != FIELD)
2123
- m->num_headers++;
2124
-
2125
- strlncat(m->headers[m->num_headers-1][0],
2126
- sizeof(m->headers[m->num_headers-1][0]),
2127
- buf,
2128
- len);
2129
-
2130
- m->last_header_element = FIELD;
2131
-
2132
- return 0;
2133
- }
2134
-
2135
- int
2136
- header_value_cb (http_parser *p, const char *buf, size_t len)
2137
- {
2138
- assert(p == &parser);
2139
- struct message *m = &messages[num_messages];
2140
-
2141
- strlncat(m->headers[m->num_headers-1][1],
2142
- sizeof(m->headers[m->num_headers-1][1]),
2143
- buf,
2144
- len);
2145
-
2146
- m->last_header_element = VALUE;
2147
-
2148
- return 0;
2149
- }
2150
-
2151
- void
2152
- check_body_is_final (const http_parser *p)
2153
- {
2154
- if (messages[num_messages].body_is_final) {
2155
- fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 "
2156
- "on last on_body callback call "
2157
- "but it doesn't! ***\n\n");
2158
- assert(0);
2159
- abort();
2160
- }
2161
- messages[num_messages].body_is_final = http_body_is_final(p);
2162
- }
2163
-
2164
- int
2165
- body_cb (http_parser *p, const char *buf, size_t len)
2166
- {
2167
- assert(p == &parser);
2168
- strlncat(messages[num_messages].body,
2169
- sizeof(messages[num_messages].body),
2170
- buf,
2171
- len);
2172
- messages[num_messages].body_size += len;
2173
- check_body_is_final(p);
2174
- // printf("body_cb: '%s'\n", requests[num_messages].body);
2175
- return 0;
2176
- }
2177
-
2178
- int
2179
- count_body_cb (http_parser *p, const char *buf, size_t len)
2180
- {
2181
- assert(p == &parser);
2182
- assert(buf);
2183
- messages[num_messages].body_size += len;
2184
- check_body_is_final(p);
2185
- return 0;
2186
- }
2187
-
2188
- int
2189
- message_begin_cb (http_parser *p)
2190
- {
2191
- assert(p == &parser);
2192
- assert(!messages[num_messages].message_begin_cb_called);
2193
- messages[num_messages].message_begin_cb_called = TRUE;
2194
- return 0;
2195
- }
2196
-
2197
- int
2198
- headers_complete_cb (http_parser *p)
2199
- {
2200
- assert(p == &parser);
2201
- messages[num_messages].method = parser.method;
2202
- messages[num_messages].status_code = parser.status_code;
2203
- messages[num_messages].http_major = parser.http_major;
2204
- messages[num_messages].http_minor = parser.http_minor;
2205
- messages[num_messages].headers_complete_cb_called = TRUE;
2206
- messages[num_messages].should_keep_alive = http_should_keep_alive(&parser);
2207
- return 0;
2208
- }
2209
-
2210
- int
2211
- message_complete_cb (http_parser *p)
2212
- {
2213
- assert(p == &parser);
2214
- if (messages[num_messages].should_keep_alive !=
2215
- http_should_keep_alive(&parser))
2216
- {
2217
- fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same "
2218
- "value in both on_message_complete and on_headers_complete "
2219
- "but it doesn't! ***\n\n");
2220
- assert(0);
2221
- abort();
2222
- }
2223
-
2224
- if (messages[num_messages].body_size &&
2225
- http_body_is_final(p) &&
2226
- !messages[num_messages].body_is_final)
2227
- {
2228
- fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 "
2229
- "on last on_body callback call "
2230
- "but it doesn't! ***\n\n");
2231
- assert(0);
2232
- abort();
2233
- }
2234
-
2235
- messages[num_messages].message_complete_cb_called = TRUE;
2236
-
2237
- messages[num_messages].message_complete_on_eof = currently_parsing_eof;
2238
-
2239
- num_messages++;
2240
- return 0;
2241
- }
2242
-
2243
- int
2244
- response_status_cb (http_parser *p, const char *buf, size_t len)
2245
- {
2246
- assert(p == &parser);
2247
-
2248
- messages[num_messages].status_cb_called = TRUE;
2249
-
2250
- strlncat(messages[num_messages].response_status,
2251
- sizeof(messages[num_messages].response_status),
2252
- buf,
2253
- len);
2254
- return 0;
2255
- }
2256
-
2257
- int
2258
- chunk_header_cb (http_parser *p)
2259
- {
2260
- assert(p == &parser);
2261
- int chunk_idx = messages[num_messages].num_chunks;
2262
- messages[num_messages].num_chunks++;
2263
- if (chunk_idx < MAX_CHUNKS) {
2264
- messages[num_messages].chunk_lengths[chunk_idx] = p->content_length;
2265
- }
2266
-
2267
- return 0;
2268
- }
2269
-
2270
- int
2271
- chunk_complete_cb (http_parser *p)
2272
- {
2273
- assert(p == &parser);
2274
-
2275
- /* Here we want to verify that each chunk_header_cb is matched by a
2276
- * chunk_complete_cb, so not only should the total number of calls to
2277
- * both callbacks be the same, but they also should be interleaved
2278
- * properly */
2279
- assert(messages[num_messages].num_chunks ==
2280
- messages[num_messages].num_chunks_complete + 1);
2281
-
2282
- messages[num_messages].num_chunks_complete++;
2283
- return 0;
2284
- }
2285
-
2286
- /* These dontcall_* callbacks exist so that we can verify that when we're
2287
- * paused, no additional callbacks are invoked */
2288
- int
2289
- dontcall_message_begin_cb (http_parser *p)
2290
- {
2291
- if (p) { } // gcc
2292
- fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n");
2293
- abort();
2294
- }
2295
-
2296
- int
2297
- dontcall_header_field_cb (http_parser *p, const char *buf, size_t len)
2298
- {
2299
- if (p || buf || len) { } // gcc
2300
- fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n");
2301
- abort();
2302
- }
2303
-
2304
- int
2305
- dontcall_header_value_cb (http_parser *p, const char *buf, size_t len)
2306
- {
2307
- if (p || buf || len) { } // gcc
2308
- fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n");
2309
- abort();
2310
- }
2311
-
2312
- int
2313
- dontcall_request_url_cb (http_parser *p, const char *buf, size_t len)
2314
- {
2315
- if (p || buf || len) { } // gcc
2316
- fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n");
2317
- abort();
2318
- }
2319
-
2320
- int
2321
- dontcall_body_cb (http_parser *p, const char *buf, size_t len)
2322
- {
2323
- if (p || buf || len) { } // gcc
2324
- fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n");
2325
- abort();
2326
- }
2327
-
2328
- int
2329
- dontcall_headers_complete_cb (http_parser *p)
2330
- {
2331
- if (p) { } // gcc
2332
- fprintf(stderr, "\n\n*** on_headers_complete() called on paused "
2333
- "parser ***\n\n");
2334
- abort();
2335
- }
2336
-
2337
- int
2338
- dontcall_message_complete_cb (http_parser *p)
2339
- {
2340
- if (p) { } // gcc
2341
- fprintf(stderr, "\n\n*** on_message_complete() called on paused "
2342
- "parser ***\n\n");
2343
- abort();
2344
- }
2345
-
2346
- int
2347
- dontcall_response_status_cb (http_parser *p, const char *buf, size_t len)
2348
- {
2349
- if (p || buf || len) { } // gcc
2350
- fprintf(stderr, "\n\n*** on_status() called on paused parser ***\n\n");
2351
- abort();
2352
- }
2353
-
2354
- int
2355
- dontcall_chunk_header_cb (http_parser *p)
2356
- {
2357
- if (p) { } // gcc
2358
- fprintf(stderr, "\n\n*** on_chunk_header() called on paused parser ***\n\n");
2359
- exit(1);
2360
- }
2361
-
2362
- int
2363
- dontcall_chunk_complete_cb (http_parser *p)
2364
- {
2365
- if (p) { } // gcc
2366
- fprintf(stderr, "\n\n*** on_chunk_complete() "
2367
- "called on paused parser ***\n\n");
2368
- exit(1);
2369
- }
2370
-
2371
- static http_parser_settings settings_dontcall =
2372
- {.on_message_begin = dontcall_message_begin_cb
2373
- ,.on_header_field = dontcall_header_field_cb
2374
- ,.on_header_value = dontcall_header_value_cb
2375
- ,.on_url = dontcall_request_url_cb
2376
- ,.on_status = dontcall_response_status_cb
2377
- ,.on_body = dontcall_body_cb
2378
- ,.on_headers_complete = dontcall_headers_complete_cb
2379
- ,.on_message_complete = dontcall_message_complete_cb
2380
- ,.on_chunk_header = dontcall_chunk_header_cb
2381
- ,.on_chunk_complete = dontcall_chunk_complete_cb
2382
- };
2383
-
2384
- /* These pause_* callbacks always pause the parser and just invoke the regular
2385
- * callback that tracks content. Before returning, we overwrite the parser
2386
- * settings to point to the _dontcall variety so that we can verify that
2387
- * the pause actually did, you know, pause. */
2388
- int
2389
- pause_message_begin_cb (http_parser *p)
2390
- {
2391
- http_parser_pause(p, 1);
2392
- *current_pause_parser = settings_dontcall;
2393
- return message_begin_cb(p);
2394
- }
2395
-
2396
- int
2397
- pause_header_field_cb (http_parser *p, const char *buf, size_t len)
2398
- {
2399
- http_parser_pause(p, 1);
2400
- *current_pause_parser = settings_dontcall;
2401
- return header_field_cb(p, buf, len);
2402
- }
2403
-
2404
- int
2405
- pause_header_value_cb (http_parser *p, const char *buf, size_t len)
2406
- {
2407
- http_parser_pause(p, 1);
2408
- *current_pause_parser = settings_dontcall;
2409
- return header_value_cb(p, buf, len);
2410
- }
2411
-
2412
- int
2413
- pause_request_url_cb (http_parser *p, const char *buf, size_t len)
2414
- {
2415
- http_parser_pause(p, 1);
2416
- *current_pause_parser = settings_dontcall;
2417
- return request_url_cb(p, buf, len);
2418
- }
2419
-
2420
- int
2421
- pause_body_cb (http_parser *p, const char *buf, size_t len)
2422
- {
2423
- http_parser_pause(p, 1);
2424
- *current_pause_parser = settings_dontcall;
2425
- return body_cb(p, buf, len);
2426
- }
2427
-
2428
- int
2429
- pause_headers_complete_cb (http_parser *p)
2430
- {
2431
- http_parser_pause(p, 1);
2432
- *current_pause_parser = settings_dontcall;
2433
- return headers_complete_cb(p);
2434
- }
2435
-
2436
- int
2437
- pause_message_complete_cb (http_parser *p)
2438
- {
2439
- http_parser_pause(p, 1);
2440
- *current_pause_parser = settings_dontcall;
2441
- return message_complete_cb(p);
2442
- }
2443
-
2444
- int
2445
- pause_response_status_cb (http_parser *p, const char *buf, size_t len)
2446
- {
2447
- http_parser_pause(p, 1);
2448
- *current_pause_parser = settings_dontcall;
2449
- return response_status_cb(p, buf, len);
2450
- }
2451
-
2452
- int
2453
- pause_chunk_header_cb (http_parser *p)
2454
- {
2455
- http_parser_pause(p, 1);
2456
- *current_pause_parser = settings_dontcall;
2457
- return chunk_header_cb(p);
2458
- }
2459
-
2460
- int
2461
- pause_chunk_complete_cb (http_parser *p)
2462
- {
2463
- http_parser_pause(p, 1);
2464
- *current_pause_parser = settings_dontcall;
2465
- return chunk_complete_cb(p);
2466
- }
2467
-
2468
- int
2469
- connect_headers_complete_cb (http_parser *p)
2470
- {
2471
- headers_complete_cb(p);
2472
- return 1;
2473
- }
2474
-
2475
- int
2476
- connect_message_complete_cb (http_parser *p)
2477
- {
2478
- messages[num_messages].should_keep_alive = http_should_keep_alive(&parser);
2479
- return message_complete_cb(p);
2480
- }
2481
-
2482
- static http_parser_settings settings_pause =
2483
- {.on_message_begin = pause_message_begin_cb
2484
- ,.on_header_field = pause_header_field_cb
2485
- ,.on_header_value = pause_header_value_cb
2486
- ,.on_url = pause_request_url_cb
2487
- ,.on_status = pause_response_status_cb
2488
- ,.on_body = pause_body_cb
2489
- ,.on_headers_complete = pause_headers_complete_cb
2490
- ,.on_message_complete = pause_message_complete_cb
2491
- ,.on_chunk_header = pause_chunk_header_cb
2492
- ,.on_chunk_complete = pause_chunk_complete_cb
2493
- };
2494
-
2495
- static http_parser_settings settings =
2496
- {.on_message_begin = message_begin_cb
2497
- ,.on_header_field = header_field_cb
2498
- ,.on_header_value = header_value_cb
2499
- ,.on_url = request_url_cb
2500
- ,.on_status = response_status_cb
2501
- ,.on_body = body_cb
2502
- ,.on_headers_complete = headers_complete_cb
2503
- ,.on_message_complete = message_complete_cb
2504
- ,.on_chunk_header = chunk_header_cb
2505
- ,.on_chunk_complete = chunk_complete_cb
2506
- };
2507
-
2508
- static http_parser_settings settings_count_body =
2509
- {.on_message_begin = message_begin_cb
2510
- ,.on_header_field = header_field_cb
2511
- ,.on_header_value = header_value_cb
2512
- ,.on_url = request_url_cb
2513
- ,.on_status = response_status_cb
2514
- ,.on_body = count_body_cb
2515
- ,.on_headers_complete = headers_complete_cb
2516
- ,.on_message_complete = message_complete_cb
2517
- ,.on_chunk_header = chunk_header_cb
2518
- ,.on_chunk_complete = chunk_complete_cb
2519
- };
2520
-
2521
- static http_parser_settings settings_connect =
2522
- {.on_message_begin = message_begin_cb
2523
- ,.on_header_field = header_field_cb
2524
- ,.on_header_value = header_value_cb
2525
- ,.on_url = request_url_cb
2526
- ,.on_status = response_status_cb
2527
- ,.on_body = dontcall_body_cb
2528
- ,.on_headers_complete = connect_headers_complete_cb
2529
- ,.on_message_complete = connect_message_complete_cb
2530
- ,.on_chunk_header = chunk_header_cb
2531
- ,.on_chunk_complete = chunk_complete_cb
2532
- };
2533
-
2534
- static http_parser_settings settings_null =
2535
- {.on_message_begin = 0
2536
- ,.on_header_field = 0
2537
- ,.on_header_value = 0
2538
- ,.on_url = 0
2539
- ,.on_status = 0
2540
- ,.on_body = 0
2541
- ,.on_headers_complete = 0
2542
- ,.on_message_complete = 0
2543
- ,.on_chunk_header = 0
2544
- ,.on_chunk_complete = 0
2545
- };
2546
-
2547
- void
2548
- parser_init (enum http_parser_type type)
2549
- {
2550
- num_messages = 0;
2551
- http_parser_init(&parser, type);
2552
- memset(&messages, 0, sizeof messages);
2553
- }
2554
-
2555
- size_t parse (const char *buf, size_t len)
2556
- {
2557
- size_t nparsed;
2558
- currently_parsing_eof = (len == 0);
2559
- nparsed = http_parser_execute(&parser, &settings, buf, len);
2560
- return nparsed;
2561
- }
2562
-
2563
- size_t parse_count_body (const char *buf, size_t len)
2564
- {
2565
- size_t nparsed;
2566
- currently_parsing_eof = (len == 0);
2567
- nparsed = http_parser_execute(&parser, &settings_count_body, buf, len);
2568
- return nparsed;
2569
- }
2570
-
2571
- size_t parse_pause (const char *buf, size_t len)
2572
- {
2573
- size_t nparsed;
2574
- http_parser_settings s = settings_pause;
2575
-
2576
- currently_parsing_eof = (len == 0);
2577
- current_pause_parser = &s;
2578
- nparsed = http_parser_execute(&parser, current_pause_parser, buf, len);
2579
- return nparsed;
2580
- }
2581
-
2582
- size_t parse_connect (const char *buf, size_t len)
2583
- {
2584
- size_t nparsed;
2585
- currently_parsing_eof = (len == 0);
2586
- nparsed = http_parser_execute(&parser, &settings_connect, buf, len);
2587
- return nparsed;
2588
- }
2589
-
2590
- static inline int
2591
- check_str_eq (const struct message *m,
2592
- const char *prop,
2593
- const char *expected,
2594
- const char *found) {
2595
- if ((expected == NULL) != (found == NULL)) {
2596
- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name);
2597
- printf("expected %s\n", (expected == NULL) ? "NULL" : expected);
2598
- printf(" found %s\n", (found == NULL) ? "NULL" : found);
2599
- return 0;
2600
- }
2601
- if (expected != NULL && 0 != strcmp(expected, found)) {
2602
- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name);
2603
- printf("expected '%s'\n", expected);
2604
- printf(" found '%s'\n", found);
2605
- return 0;
2606
- }
2607
- return 1;
2608
- }
2609
-
2610
- static inline int
2611
- check_num_eq (const struct message *m,
2612
- const char *prop,
2613
- int expected,
2614
- int found) {
2615
- if (expected != found) {
2616
- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name);
2617
- printf("expected %d\n", expected);
2618
- printf(" found %d\n", found);
2619
- return 0;
2620
- }
2621
- return 1;
2622
- }
2623
-
2624
- #define MESSAGE_CHECK_STR_EQ(expected, found, prop) \
2625
- if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0
2626
-
2627
- #define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \
2628
- if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0
2629
-
2630
- #define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \
2631
- do { \
2632
- char ubuf[256]; \
2633
- \
2634
- if ((u)->field_set & (1 << (fn))) { \
2635
- memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \
2636
- (u)->field_data[(fn)].len); \
2637
- ubuf[(u)->field_data[(fn)].len] = '\0'; \
2638
- } else { \
2639
- ubuf[0] = '\0'; \
2640
- } \
2641
- \
2642
- check_str_eq(expected, #prop, expected->prop, ubuf); \
2643
- } while(0)
2644
-
2645
- int
2646
- message_eq (int index, int connect, const struct message *expected)
2647
- {
2648
- int i;
2649
- struct message *m = &messages[index];
2650
-
2651
- MESSAGE_CHECK_NUM_EQ(expected, m, http_major);
2652
- MESSAGE_CHECK_NUM_EQ(expected, m, http_minor);
2653
-
2654
- if (expected->type == HTTP_REQUEST) {
2655
- MESSAGE_CHECK_NUM_EQ(expected, m, method);
2656
- } else {
2657
- MESSAGE_CHECK_NUM_EQ(expected, m, status_code);
2658
- MESSAGE_CHECK_STR_EQ(expected, m, response_status);
2659
- assert(m->status_cb_called);
2660
- }
2661
-
2662
- if (!connect) {
2663
- MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive);
2664
- MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof);
2665
- }
2666
-
2667
- assert(m->message_begin_cb_called);
2668
- assert(m->headers_complete_cb_called);
2669
- assert(m->message_complete_cb_called);
2670
-
2671
-
2672
- MESSAGE_CHECK_STR_EQ(expected, m, request_url);
2673
-
2674
- /* Check URL components; we can't do this w/ CONNECT since it doesn't
2675
- * send us a well-formed URL.
2676
- */
2677
- if (*m->request_url && m->method != HTTP_CONNECT) {
2678
- struct http_parser_url u;
2679
-
2680
- if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) {
2681
- fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n",
2682
- m->request_url);
2683
- abort();
2684
- }
2685
-
2686
- if (expected->host) {
2687
- MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST);
2688
- }
2689
-
2690
- if (expected->userinfo) {
2691
- MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO);
2692
- }
2693
-
2694
- m->port = (u.field_set & (1 << UF_PORT)) ?
2695
- u.port : 0;
2696
-
2697
- MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY);
2698
- MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT);
2699
- MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH);
2700
- MESSAGE_CHECK_NUM_EQ(expected, m, port);
2701
- }
2702
-
2703
- if (connect) {
2704
- check_num_eq(m, "body_size", 0, m->body_size);
2705
- } else if (expected->body_size) {
2706
- MESSAGE_CHECK_NUM_EQ(expected, m, body_size);
2707
- } else {
2708
- MESSAGE_CHECK_STR_EQ(expected, m, body);
2709
- }
2710
-
2711
- if (connect) {
2712
- check_num_eq(m, "num_chunks_complete", 0, m->num_chunks_complete);
2713
- } else {
2714
- assert(m->num_chunks == m->num_chunks_complete);
2715
- MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete);
2716
- for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) {
2717
- MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]);
2718
- }
2719
- }
2720
-
2721
- MESSAGE_CHECK_NUM_EQ(expected, m, num_headers);
2722
-
2723
- int r;
2724
- for (i = 0; i < m->num_headers; i++) {
2725
- r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]);
2726
- if (!r) return 0;
2727
- r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]);
2728
- if (!r) return 0;
2729
- }
2730
-
2731
- if (!connect) {
2732
- MESSAGE_CHECK_STR_EQ(expected, m, upgrade);
2733
- }
2734
-
2735
- return 1;
2736
- }
2737
-
2738
- /* Given a sequence of varargs messages, return the number of them that the
2739
- * parser should successfully parse, taking into account that upgraded
2740
- * messages prevent all subsequent messages from being parsed.
2741
- */
2742
- size_t
2743
- count_parsed_messages(const size_t nmsgs, ...) {
2744
- size_t i;
2745
- va_list ap;
2746
-
2747
- va_start(ap, nmsgs);
2748
-
2749
- for (i = 0; i < nmsgs; i++) {
2750
- struct message *m = va_arg(ap, struct message *);
2751
-
2752
- if (m->upgrade) {
2753
- va_end(ap);
2754
- return i + 1;
2755
- }
2756
- }
2757
-
2758
- va_end(ap);
2759
- return nmsgs;
2760
- }
2761
-
2762
- /* Given a sequence of bytes and the number of these that we were able to
2763
- * parse, verify that upgrade bodies are correct.
2764
- */
2765
- void
2766
- upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) {
2767
- va_list ap;
2768
- size_t i;
2769
- size_t off = 0;
2770
-
2771
- va_start(ap, nmsgs);
2772
-
2773
- for (i = 0; i < nmsgs; i++) {
2774
- struct message *m = va_arg(ap, struct message *);
2775
-
2776
- off += strlen(m->raw);
2777
-
2778
- if (m->upgrade) {
2779
- off -= strlen(m->upgrade);
2780
-
2781
- /* Check the portion of the response after its specified upgrade */
2782
- if (!check_str_eq(m, "upgrade", body + off, body + nread)) {
2783
- abort();
2784
- }
2785
-
2786
- /* Fix up the response so that message_eq() will verify the beginning
2787
- * of the upgrade */
2788
- *(body + nread + strlen(m->upgrade)) = '\0';
2789
- messages[num_messages -1 ].upgrade = body + nread;
2790
-
2791
- va_end(ap);
2792
- return;
2793
- }
2794
- }
2795
-
2796
- va_end(ap);
2797
- printf("\n\n*** Error: expected a message with upgrade ***\n");
2798
-
2799
- abort();
2800
- }
2801
-
2802
- static void
2803
- print_error (const char *raw, size_t error_location)
2804
- {
2805
- fprintf(stderr, "\n*** %s ***\n\n",
2806
- http_errno_description(HTTP_PARSER_ERRNO(&parser)));
2807
-
2808
- int this_line = 0, char_len = 0;
2809
- size_t i, j, len = strlen(raw), error_location_line = 0;
2810
- for (i = 0; i < len; i++) {
2811
- if (i == error_location) this_line = 1;
2812
- switch (raw[i]) {
2813
- case '\r':
2814
- char_len = 2;
2815
- fprintf(stderr, "\\r");
2816
- break;
2817
-
2818
- case '\n':
2819
- fprintf(stderr, "\\n\n");
2820
-
2821
- if (this_line) goto print;
2822
-
2823
- error_location_line = 0;
2824
- continue;
2825
-
2826
- default:
2827
- char_len = 1;
2828
- fputc(raw[i], stderr);
2829
- break;
2830
- }
2831
- if (!this_line) error_location_line += char_len;
2832
- }
2833
-
2834
- fprintf(stderr, "[eof]\n");
2835
-
2836
- print:
2837
- for (j = 0; j < error_location_line; j++) {
2838
- fputc(' ', stderr);
2839
- }
2840
- fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location);
2841
- }
2842
-
2843
- void
2844
- test_preserve_data (void)
2845
- {
2846
- char my_data[] = "application-specific data";
2847
- http_parser parser;
2848
- parser.data = my_data;
2849
- http_parser_init(&parser, HTTP_REQUEST);
2850
- if (parser.data != my_data) {
2851
- printf("\n*** parser.data not preserved accross http_parser_init ***\n\n");
2852
- abort();
2853
- }
2854
- }
2855
-
2856
- struct url_test {
2857
- const char *name;
2858
- const char *url;
2859
- int is_connect;
2860
- struct http_parser_url u;
2861
- int rv;
2862
- };
2863
-
2864
- const struct url_test url_tests[] =
2865
- { {.name="proxy request"
2866
- ,.url="http://hostname/"
2867
- ,.is_connect=0
2868
- ,.u=
2869
- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH)
2870
- ,.port=0
2871
- ,.field_data=
2872
- {{ 0, 4 } /* UF_SCHEMA */
2873
- ,{ 7, 8 } /* UF_HOST */
2874
- ,{ 0, 0 } /* UF_PORT */
2875
- ,{ 15, 1 } /* UF_PATH */
2876
- ,{ 0, 0 } /* UF_QUERY */
2877
- ,{ 0, 0 } /* UF_FRAGMENT */
2878
- ,{ 0, 0 } /* UF_USERINFO */
2879
- }
2880
- }
2881
- ,.rv=0
2882
- }
2883
-
2884
- , {.name="proxy request with port"
2885
- ,.url="http://hostname:444/"
2886
- ,.is_connect=0
2887
- ,.u=
2888
- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH)
2889
- ,.port=444
2890
- ,.field_data=
2891
- {{ 0, 4 } /* UF_SCHEMA */
2892
- ,{ 7, 8 } /* UF_HOST */
2893
- ,{ 16, 3 } /* UF_PORT */
2894
- ,{ 19, 1 } /* UF_PATH */
2895
- ,{ 0, 0 } /* UF_QUERY */
2896
- ,{ 0, 0 } /* UF_FRAGMENT */
2897
- ,{ 0, 0 } /* UF_USERINFO */
2898
- }
2899
- }
2900
- ,.rv=0
2901
- }
2902
-
2903
- , {.name="CONNECT request"
2904
- ,.url="hostname:443"
2905
- ,.is_connect=1
2906
- ,.u=
2907
- {.field_set=(1 << UF_HOST) | (1 << UF_PORT)
2908
- ,.port=443
2909
- ,.field_data=
2910
- {{ 0, 0 } /* UF_SCHEMA */
2911
- ,{ 0, 8 } /* UF_HOST */
2912
- ,{ 9, 3 } /* UF_PORT */
2913
- ,{ 0, 0 } /* UF_PATH */
2914
- ,{ 0, 0 } /* UF_QUERY */
2915
- ,{ 0, 0 } /* UF_FRAGMENT */
2916
- ,{ 0, 0 } /* UF_USERINFO */
2917
- }
2918
- }
2919
- ,.rv=0
2920
- }
2921
-
2922
- , {.name="CONNECT request but not connect"
2923
- ,.url="hostname:443"
2924
- ,.is_connect=0
2925
- ,.rv=1
2926
- }
2927
-
2928
- , {.name="proxy ipv6 request"
2929
- ,.url="http://[1:2::3:4]/"
2930
- ,.is_connect=0
2931
- ,.u=
2932
- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH)
2933
- ,.port=0
2934
- ,.field_data=
2935
- {{ 0, 4 } /* UF_SCHEMA */
2936
- ,{ 8, 8 } /* UF_HOST */
2937
- ,{ 0, 0 } /* UF_PORT */
2938
- ,{ 17, 1 } /* UF_PATH */
2939
- ,{ 0, 0 } /* UF_QUERY */
2940
- ,{ 0, 0 } /* UF_FRAGMENT */
2941
- ,{ 0, 0 } /* UF_USERINFO */
2942
- }
2943
- }
2944
- ,.rv=0
2945
- }
2946
-
2947
- , {.name="proxy ipv6 request with port"
2948
- ,.url="http://[1:2::3:4]:67/"
2949
- ,.is_connect=0
2950
- ,.u=
2951
- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH)
2952
- ,.port=67
2953
- ,.field_data=
2954
- {{ 0, 4 } /* UF_SCHEMA */
2955
- ,{ 8, 8 } /* UF_HOST */
2956
- ,{ 18, 2 } /* UF_PORT */
2957
- ,{ 20, 1 } /* UF_PATH */
2958
- ,{ 0, 0 } /* UF_QUERY */
2959
- ,{ 0, 0 } /* UF_FRAGMENT */
2960
- ,{ 0, 0 } /* UF_USERINFO */
2961
- }
2962
- }
2963
- ,.rv=0
2964
- }
2965
-
2966
- , {.name="CONNECT ipv6 address"
2967
- ,.url="[1:2::3:4]:443"
2968
- ,.is_connect=1
2969
- ,.u=
2970
- {.field_set=(1 << UF_HOST) | (1 << UF_PORT)
2971
- ,.port=443
2972
- ,.field_data=
2973
- {{ 0, 0 } /* UF_SCHEMA */
2974
- ,{ 1, 8 } /* UF_HOST */
2975
- ,{ 11, 3 } /* UF_PORT */
2976
- ,{ 0, 0 } /* UF_PATH */
2977
- ,{ 0, 0 } /* UF_QUERY */
2978
- ,{ 0, 0 } /* UF_FRAGMENT */
2979
- ,{ 0, 0 } /* UF_USERINFO */
2980
- }
2981
- }
2982
- ,.rv=0
2983
- }
2984
-
2985
- , {.name="ipv4 in ipv6 address"
2986
- ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/"
2987
- ,.is_connect=0
2988
- ,.u=
2989
- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH)
2990
- ,.port=0
2991
- ,.field_data=
2992
- {{ 0, 4 } /* UF_SCHEMA */
2993
- ,{ 8, 37 } /* UF_HOST */
2994
- ,{ 0, 0 } /* UF_PORT */
2995
- ,{ 46, 1 } /* UF_PATH */
2996
- ,{ 0, 0 } /* UF_QUERY */
2997
- ,{ 0, 0 } /* UF_FRAGMENT */
2998
- ,{ 0, 0 } /* UF_USERINFO */
2999
- }
3000
- }
3001
- ,.rv=0
3002
- }
3003
-
3004
- , {.name="extra ? in query string"
3005
- ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css,"
3006
- "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css,"
3007
- "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css"
3008
- ,.is_connect=0
3009
- ,.u=
3010
- {.field_set=(1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_QUERY)
3011
- ,.port=0
3012
- ,.field_data=
3013
- {{ 0, 4 } /* UF_SCHEMA */
3014
- ,{ 7, 10 } /* UF_HOST */
3015
- ,{ 0, 0 } /* UF_PORT */
3016
- ,{ 17, 12 } /* UF_PATH */
3017
- ,{ 30,187 } /* UF_QUERY */
3018
- ,{ 0, 0 } /* UF_FRAGMENT */
3019
- ,{ 0, 0 } /* UF_USERINFO */
3020
- }
3021
- }
3022
- ,.rv=0
3023
- }
3024
-
3025
- , {.name="space URL encoded"
3026
- ,.url="/toto.html?toto=a%20b"
3027
- ,.is_connect=0
3028
- ,.u=
3029
- {.field_set= (1<<UF_PATH) | (1<<UF_QUERY)
3030
- ,.port=0
3031
- ,.field_data=
3032
- {{ 0, 0 } /* UF_SCHEMA */
3033
- ,{ 0, 0 } /* UF_HOST */
3034
- ,{ 0, 0 } /* UF_PORT */
3035
- ,{ 0, 10 } /* UF_PATH */
3036
- ,{ 11, 10 } /* UF_QUERY */
3037
- ,{ 0, 0 } /* UF_FRAGMENT */
3038
- ,{ 0, 0 } /* UF_USERINFO */
3039
- }
3040
- }
3041
- ,.rv=0
3042
- }
3043
-
3044
-
3045
- , {.name="URL fragment"
3046
- ,.url="/toto.html#titi"
3047
- ,.is_connect=0
3048
- ,.u=
3049
- {.field_set= (1<<UF_PATH) | (1<<UF_FRAGMENT)
3050
- ,.port=0
3051
- ,.field_data=
3052
- {{ 0, 0 } /* UF_SCHEMA */
3053
- ,{ 0, 0 } /* UF_HOST */
3054
- ,{ 0, 0 } /* UF_PORT */
3055
- ,{ 0, 10 } /* UF_PATH */
3056
- ,{ 0, 0 } /* UF_QUERY */
3057
- ,{ 11, 4 } /* UF_FRAGMENT */
3058
- ,{ 0, 0 } /* UF_USERINFO */
3059
- }
3060
- }
3061
- ,.rv=0
3062
- }
3063
-
3064
- , {.name="complex URL fragment"
3065
- ,.url="http://www.webmasterworld.com/r.cgi?f=21&d=8405&url="
3066
- "http://www.example.com/index.html?foo=bar&hello=world#midpage"
3067
- ,.is_connect=0
3068
- ,.u=
3069
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_QUERY) |\
3070
- (1<<UF_FRAGMENT)
3071
- ,.port=0
3072
- ,.field_data=
3073
- {{ 0, 4 } /* UF_SCHEMA */
3074
- ,{ 7, 22 } /* UF_HOST */
3075
- ,{ 0, 0 } /* UF_PORT */
3076
- ,{ 29, 6 } /* UF_PATH */
3077
- ,{ 36, 69 } /* UF_QUERY */
3078
- ,{106, 7 } /* UF_FRAGMENT */
3079
- ,{ 0, 0 } /* UF_USERINFO */
3080
- }
3081
- }
3082
- ,.rv=0
3083
- }
3084
-
3085
- , {.name="complex URL from node js url parser doc"
3086
- ,.url="http://host.com:8080/p/a/t/h?query=string#hash"
3087
- ,.is_connect=0
3088
- ,.u=
3089
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PORT) | (1<<UF_PATH) |\
3090
- (1<<UF_QUERY) | (1<<UF_FRAGMENT)
3091
- ,.port=8080
3092
- ,.field_data=
3093
- {{ 0, 4 } /* UF_SCHEMA */
3094
- ,{ 7, 8 } /* UF_HOST */
3095
- ,{ 16, 4 } /* UF_PORT */
3096
- ,{ 20, 8 } /* UF_PATH */
3097
- ,{ 29, 12 } /* UF_QUERY */
3098
- ,{ 42, 4 } /* UF_FRAGMENT */
3099
- ,{ 0, 0 } /* UF_USERINFO */
3100
- }
3101
- }
3102
- ,.rv=0
3103
- }
3104
-
3105
- , {.name="complex URL with basic auth from node js url parser doc"
3106
- ,.url="http://a:b@host.com:8080/p/a/t/h?query=string#hash"
3107
- ,.is_connect=0
3108
- ,.u=
3109
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PORT) | (1<<UF_PATH) |\
3110
- (1<<UF_QUERY) | (1<<UF_FRAGMENT) | (1<<UF_USERINFO)
3111
- ,.port=8080
3112
- ,.field_data=
3113
- {{ 0, 4 } /* UF_SCHEMA */
3114
- ,{ 11, 8 } /* UF_HOST */
3115
- ,{ 20, 4 } /* UF_PORT */
3116
- ,{ 24, 8 } /* UF_PATH */
3117
- ,{ 33, 12 } /* UF_QUERY */
3118
- ,{ 46, 4 } /* UF_FRAGMENT */
3119
- ,{ 7, 3 } /* UF_USERINFO */
3120
- }
3121
- }
3122
- ,.rv=0
3123
- }
3124
-
3125
- , {.name="double @"
3126
- ,.url="http://a:b@@hostname:443/"
3127
- ,.is_connect=0
3128
- ,.rv=1
3129
- }
3130
-
3131
- , {.name="proxy empty host"
3132
- ,.url="http://:443/"
3133
- ,.is_connect=0
3134
- ,.rv=1
3135
- }
3136
-
3137
- , {.name="proxy empty port"
3138
- ,.url="http://hostname:/"
3139
- ,.is_connect=0
3140
- ,.rv=1
3141
- }
3142
-
3143
- , {.name="CONNECT with basic auth"
3144
- ,.url="a:b@hostname:443"
3145
- ,.is_connect=1
3146
- ,.rv=1
3147
- }
3148
-
3149
- , {.name="CONNECT empty host"
3150
- ,.url=":443"
3151
- ,.is_connect=1
3152
- ,.rv=1
3153
- }
3154
-
3155
- , {.name="CONNECT empty port"
3156
- ,.url="hostname:"
3157
- ,.is_connect=1
3158
- ,.rv=1
3159
- }
3160
-
3161
- , {.name="CONNECT with extra bits"
3162
- ,.url="hostname:443/"
3163
- ,.is_connect=1
3164
- ,.rv=1
3165
- }
3166
-
3167
- , {.name="space in URL"
3168
- ,.url="/foo bar/"
3169
- ,.rv=1 /* s_dead */
3170
- }
3171
-
3172
- , {.name="proxy basic auth with space url encoded"
3173
- ,.url="http://a%20:b@host.com/"
3174
- ,.is_connect=0
3175
- ,.u=
3176
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_USERINFO)
3177
- ,.port=0
3178
- ,.field_data=
3179
- {{ 0, 4 } /* UF_SCHEMA */
3180
- ,{ 14, 8 } /* UF_HOST */
3181
- ,{ 0, 0 } /* UF_PORT */
3182
- ,{ 22, 1 } /* UF_PATH */
3183
- ,{ 0, 0 } /* UF_QUERY */
3184
- ,{ 0, 0 } /* UF_FRAGMENT */
3185
- ,{ 7, 6 } /* UF_USERINFO */
3186
- }
3187
- }
3188
- ,.rv=0
3189
- }
3190
-
3191
- , {.name="carriage return in URL"
3192
- ,.url="/foo\rbar/"
3193
- ,.rv=1 /* s_dead */
3194
- }
3195
-
3196
- , {.name="proxy double : in URL"
3197
- ,.url="http://hostname::443/"
3198
- ,.rv=1 /* s_dead */
3199
- }
3200
-
3201
- , {.name="proxy basic auth with double :"
3202
- ,.url="http://a::b@host.com/"
3203
- ,.is_connect=0
3204
- ,.u=
3205
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_USERINFO)
3206
- ,.port=0
3207
- ,.field_data=
3208
- {{ 0, 4 } /* UF_SCHEMA */
3209
- ,{ 12, 8 } /* UF_HOST */
3210
- ,{ 0, 0 } /* UF_PORT */
3211
- ,{ 20, 1 } /* UF_PATH */
3212
- ,{ 0, 0 } /* UF_QUERY */
3213
- ,{ 0, 0 } /* UF_FRAGMENT */
3214
- ,{ 7, 4 } /* UF_USERINFO */
3215
- }
3216
- }
3217
- ,.rv=0
3218
- }
3219
-
3220
- , {.name="line feed in URL"
3221
- ,.url="/foo\nbar/"
3222
- ,.rv=1 /* s_dead */
3223
- }
3224
-
3225
- , {.name="proxy empty basic auth"
3226
- ,.url="http://@hostname/fo"
3227
- ,.u=
3228
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH)
3229
- ,.port=0
3230
- ,.field_data=
3231
- {{ 0, 4 } /* UF_SCHEMA */
3232
- ,{ 8, 8 } /* UF_HOST */
3233
- ,{ 0, 0 } /* UF_PORT */
3234
- ,{ 16, 3 } /* UF_PATH */
3235
- ,{ 0, 0 } /* UF_QUERY */
3236
- ,{ 0, 0 } /* UF_FRAGMENT */
3237
- ,{ 0, 0 } /* UF_USERINFO */
3238
- }
3239
- }
3240
- ,.rv=0
3241
- }
3242
- , {.name="proxy line feed in hostname"
3243
- ,.url="http://host\name/fo"
3244
- ,.rv=1 /* s_dead */
3245
- }
3246
-
3247
- , {.name="proxy % in hostname"
3248
- ,.url="http://host%name/fo"
3249
- ,.rv=1 /* s_dead */
3250
- }
3251
-
3252
- , {.name="proxy ; in hostname"
3253
- ,.url="http://host;ame/fo"
3254
- ,.rv=1 /* s_dead */
3255
- }
3256
-
3257
- , {.name="proxy basic auth with unreservedchars"
3258
- ,.url="http://a!;-_!=+$@host.com/"
3259
- ,.is_connect=0
3260
- ,.u=
3261
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_USERINFO)
3262
- ,.port=0
3263
- ,.field_data=
3264
- {{ 0, 4 } /* UF_SCHEMA */
3265
- ,{ 17, 8 } /* UF_HOST */
3266
- ,{ 0, 0 } /* UF_PORT */
3267
- ,{ 25, 1 } /* UF_PATH */
3268
- ,{ 0, 0 } /* UF_QUERY */
3269
- ,{ 0, 0 } /* UF_FRAGMENT */
3270
- ,{ 7, 9 } /* UF_USERINFO */
3271
- }
3272
- }
3273
- ,.rv=0
3274
- }
3275
-
3276
- , {.name="proxy only empty basic auth"
3277
- ,.url="http://@/fo"
3278
- ,.rv=1 /* s_dead */
3279
- }
3280
-
3281
- , {.name="proxy only basic auth"
3282
- ,.url="http://toto@/fo"
3283
- ,.rv=1 /* s_dead */
3284
- }
3285
-
3286
- , {.name="proxy emtpy hostname"
3287
- ,.url="http:///fo"
3288
- ,.rv=1 /* s_dead */
3289
- }
3290
-
3291
- , {.name="proxy = in URL"
3292
- ,.url="http://host=ame/fo"
3293
- ,.rv=1 /* s_dead */
3294
- }
3295
-
3296
- , {.name="ipv6 address with Zone ID"
3297
- ,.url="http://[fe80::a%25eth0]/"
3298
- ,.is_connect=0
3299
- ,.u=
3300
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH)
3301
- ,.port=0
3302
- ,.field_data=
3303
- {{ 0, 4 } /* UF_SCHEMA */
3304
- ,{ 8, 14 } /* UF_HOST */
3305
- ,{ 0, 0 } /* UF_PORT */
3306
- ,{ 23, 1 } /* UF_PATH */
3307
- ,{ 0, 0 } /* UF_QUERY */
3308
- ,{ 0, 0 } /* UF_FRAGMENT */
3309
- ,{ 0, 0 } /* UF_USERINFO */
3310
- }
3311
- }
3312
- ,.rv=0
3313
- }
3314
-
3315
- , {.name="ipv6 address with Zone ID, but '%' is not percent-encoded"
3316
- ,.url="http://[fe80::a%eth0]/"
3317
- ,.is_connect=0
3318
- ,.u=
3319
- {.field_set= (1<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH)
3320
- ,.port=0
3321
- ,.field_data=
3322
- {{ 0, 4 } /* UF_SCHEMA */
3323
- ,{ 8, 12 } /* UF_HOST */
3324
- ,{ 0, 0 } /* UF_PORT */
3325
- ,{ 21, 1 } /* UF_PATH */
3326
- ,{ 0, 0 } /* UF_QUERY */
3327
- ,{ 0, 0 } /* UF_FRAGMENT */
3328
- ,{ 0, 0 } /* UF_USERINFO */
3329
- }
3330
- }
3331
- ,.rv=0
3332
- }
3333
-
3334
- , {.name="ipv6 address ending with '%'"
3335
- ,.url="http://[fe80::a%]/"
3336
- ,.rv=1 /* s_dead */
3337
- }
3338
-
3339
- , {.name="ipv6 address with Zone ID including bad character"
3340
- ,.url="http://[fe80::a%$HOME]/"
3341
- ,.rv=1 /* s_dead */
3342
- }
3343
-
3344
- , {.name="just ipv6 Zone ID"
3345
- ,.url="http://[%eth0]/"
3346
- ,.rv=1 /* s_dead */
3347
- }
3348
-
3349
- , {.name="empty url"
3350
- ,.url=""
3351
- ,.is_connect=0
3352
- ,.rv=1
3353
- }
3354
-
3355
- , {.name="NULL url"
3356
- ,.url=NULL
3357
- ,.is_connect=0
3358
- ,.rv=1
3359
- }
3360
-
3361
- , {.name="full of spaces url"
3362
- ,.url=" "
3363
- ,.is_connect=0
3364
- ,.rv=1
3365
- }
3366
-
3367
- #if HTTP_PARSER_STRICT
3368
-
3369
- , {.name="tab in URL"
3370
- ,.url="/foo\tbar/"
3371
- ,.rv=1 /* s_dead */
3372
- }
3373
-
3374
- , {.name="form feed in URL"
3375
- ,.url="/foo\fbar/"
3376
- ,.rv=1 /* s_dead */
3377
- }
3378
-
3379
- #else /* !HTTP_PARSER_STRICT */
3380
-
3381
- , {.name="tab in URL"
3382
- ,.url="/foo\tbar/"
3383
- ,.u=
3384
- {.field_set=(1 << UF_PATH)
3385
- ,.field_data=
3386
- {{ 0, 0 } /* UF_SCHEMA */
3387
- ,{ 0, 0 } /* UF_HOST */
3388
- ,{ 0, 0 } /* UF_PORT */
3389
- ,{ 0, 9 } /* UF_PATH */
3390
- ,{ 0, 0 } /* UF_QUERY */
3391
- ,{ 0, 0 } /* UF_FRAGMENT */
3392
- ,{ 0, 0 } /* UF_USERINFO */
3393
- }
3394
- }
3395
- ,.rv=0
3396
- }
3397
-
3398
- , {.name="form feed in URL"
3399
- ,.url="/foo\fbar/"
3400
- ,.u=
3401
- {.field_set=(1 << UF_PATH)
3402
- ,.field_data=
3403
- {{ 0, 0 } /* UF_SCHEMA */
3404
- ,{ 0, 0 } /* UF_HOST */
3405
- ,{ 0, 0 } /* UF_PORT */
3406
- ,{ 0, 9 } /* UF_PATH */
3407
- ,{ 0, 0 } /* UF_QUERY */
3408
- ,{ 0, 0 } /* UF_FRAGMENT */
3409
- ,{ 0, 0 } /* UF_USERINFO */
3410
- }
3411
- }
3412
- ,.rv=0
3413
- }
3414
- #endif
3415
- };
3416
-
3417
- void
3418
- dump_url (const char *url, const struct http_parser_url *u)
3419
- {
3420
- unsigned int i;
3421
-
3422
- printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port);
3423
- for (i = 0; i < UF_MAX; i++) {
3424
- if ((u->field_set & (1 << i)) == 0) {
3425
- printf("\tfield_data[%u]: unset\n", i);
3426
- continue;
3427
- }
3428
-
3429
- printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"",
3430
- i,
3431
- u->field_data[i].off,
3432
- u->field_data[i].len,
3433
- u->field_data[i].len,
3434
- url + u->field_data[i].off);
3435
- }
3436
- }
3437
-
3438
- void
3439
- test_parse_url (void)
3440
- {
3441
- struct http_parser_url u;
3442
- const struct url_test *test;
3443
- unsigned int i;
3444
- int rv;
3445
-
3446
- for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) {
3447
- test = &url_tests[i];
3448
- memset(&u, 0, sizeof(u));
3449
-
3450
- rv = http_parser_parse_url(test->url,
3451
- test->url ? strlen(test->url) : 0,
3452
- test->is_connect,
3453
- &u);
3454
-
3455
- if (test->rv == 0) {
3456
- if (rv != 0) {
3457
- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, "
3458
- "unexpected rv %d ***\n\n", test->url, test->name, rv);
3459
- abort();
3460
- }
3461
-
3462
- if (memcmp(&u, &test->u, sizeof(u)) != 0) {
3463
- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n",
3464
- test->url, test->name);
3465
-
3466
- printf("target http_parser_url:\n");
3467
- dump_url(test->url, &test->u);
3468
- printf("result http_parser_url:\n");
3469
- dump_url(test->url, &u);
3470
-
3471
- abort();
3472
- }
3473
- } else {
3474
- /* test->rv != 0 */
3475
- if (rv == 0) {
3476
- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, "
3477
- "unexpected rv %d ***\n\n", test->url, test->name, rv);
3478
- abort();
3479
- }
3480
- }
3481
- }
3482
- }
3483
-
3484
- void
3485
- test_method_str (void)
3486
- {
3487
- assert(0 == strcmp("GET", http_method_str(HTTP_GET)));
3488
- assert(0 == strcmp("<unknown>", http_method_str(1337)));
3489
- }
3490
-
3491
- void
3492
- test_status_str (void)
3493
- {
3494
- assert(0 == strcmp("OK", http_status_str(HTTP_STATUS_OK)));
3495
- assert(0 == strcmp("Not Found", http_status_str(HTTP_STATUS_NOT_FOUND)));
3496
- assert(0 == strcmp("<unknown>", http_status_str(1337)));
3497
- }
3498
-
3499
- void
3500
- test_message (const struct message *message)
3501
- {
3502
- size_t raw_len = strlen(message->raw);
3503
- size_t msg1len;
3504
- for (msg1len = 0; msg1len < raw_len; msg1len++) {
3505
- parser_init(message->type);
3506
-
3507
- size_t read;
3508
- const char *msg1 = message->raw;
3509
- const char *msg2 = msg1 + msg1len;
3510
- size_t msg2len = raw_len - msg1len;
3511
-
3512
- if (msg1len) {
3513
- assert(num_messages == 0);
3514
- messages[0].headers_complete_cb_called = FALSE;
3515
-
3516
- read = parse(msg1, msg1len);
3517
-
3518
- if (!messages[0].headers_complete_cb_called && parser.nread != read) {
3519
- assert(parser.nread == read);
3520
- print_error(msg1, read);
3521
- abort();
3522
- }
3523
-
3524
- if (message->upgrade && parser.upgrade && num_messages > 0) {
3525
- messages[num_messages - 1].upgrade = msg1 + read;
3526
- goto test;
3527
- }
3528
-
3529
- if (read != msg1len) {
3530
- print_error(msg1, read);
3531
- abort();
3532
- }
3533
- }
3534
-
3535
-
3536
- read = parse(msg2, msg2len);
3537
-
3538
- if (message->upgrade && parser.upgrade) {
3539
- messages[num_messages - 1].upgrade = msg2 + read;
3540
- goto test;
3541
- }
3542
-
3543
- if (read != msg2len) {
3544
- print_error(msg2, read);
3545
- abort();
3546
- }
3547
-
3548
- read = parse(NULL, 0);
3549
-
3550
- if (read != 0) {
3551
- print_error(message->raw, read);
3552
- abort();
3553
- }
3554
-
3555
- test:
3556
-
3557
- if (num_messages != 1) {
3558
- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name);
3559
- abort();
3560
- }
3561
-
3562
- if(!message_eq(0, 0, message)) abort();
3563
- }
3564
- }
3565
-
3566
- void
3567
- test_message_count_body (const struct message *message)
3568
- {
3569
- parser_init(message->type);
3570
-
3571
- size_t read;
3572
- size_t l = strlen(message->raw);
3573
- size_t i, toread;
3574
- size_t chunk = 4024;
3575
-
3576
- for (i = 0; i < l; i+= chunk) {
3577
- toread = MIN(l-i, chunk);
3578
- read = parse_count_body(message->raw + i, toread);
3579
- if (read != toread) {
3580
- print_error(message->raw, read);
3581
- abort();
3582
- }
3583
- }
3584
-
3585
-
3586
- read = parse_count_body(NULL, 0);
3587
- if (read != 0) {
3588
- print_error(message->raw, read);
3589
- abort();
3590
- }
3591
-
3592
- if (num_messages != 1) {
3593
- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name);
3594
- abort();
3595
- }
3596
-
3597
- if(!message_eq(0, 0, message)) abort();
3598
- }
3599
-
3600
- void
3601
- test_simple_type (const char *buf,
3602
- enum http_errno err_expected,
3603
- enum http_parser_type type)
3604
- {
3605
- parser_init(type);
3606
-
3607
- enum http_errno err;
3608
-
3609
- parse(buf, strlen(buf));
3610
- err = HTTP_PARSER_ERRNO(&parser);
3611
- parse(NULL, 0);
3612
-
3613
- /* In strict mode, allow us to pass with an unexpected HPE_STRICT as
3614
- * long as the caller isn't expecting success.
3615
- */
3616
- #if HTTP_PARSER_STRICT
3617
- if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) {
3618
- #else
3619
- if (err_expected != err) {
3620
- #endif
3621
- fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n",
3622
- http_errno_name(err_expected), http_errno_name(err), buf);
3623
- abort();
3624
- }
3625
- }
3626
-
3627
- void
3628
- test_simple (const char *buf, enum http_errno err_expected)
3629
- {
3630
- test_simple_type(buf, err_expected, HTTP_REQUEST);
3631
- }
3632
-
3633
- void
3634
- test_invalid_header_content (int req, const char* str)
3635
- {
3636
- http_parser parser;
3637
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3638
- size_t parsed;
3639
- const char *buf;
3640
- buf = req ?
3641
- "GET / HTTP/1.1\r\n" :
3642
- "HTTP/1.1 200 OK\r\n";
3643
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3644
- assert(parsed == strlen(buf));
3645
-
3646
- buf = str;
3647
- size_t buflen = strlen(buf);
3648
-
3649
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3650
- if (parsed != buflen) {
3651
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN);
3652
- return;
3653
- }
3654
-
3655
- fprintf(stderr,
3656
- "\n*** Error expected but none in invalid header content test ***\n");
3657
- abort();
3658
- }
3659
-
3660
- void
3661
- test_invalid_header_field_content_error (int req)
3662
- {
3663
- test_invalid_header_content(req, "Foo: F\01ailure");
3664
- test_invalid_header_content(req, "Foo: B\02ar");
3665
- }
3666
-
3667
- void
3668
- test_invalid_header_field (int req, const char* str)
3669
- {
3670
- http_parser parser;
3671
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3672
- size_t parsed;
3673
- const char *buf;
3674
- buf = req ?
3675
- "GET / HTTP/1.1\r\n" :
3676
- "HTTP/1.1 200 OK\r\n";
3677
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3678
- assert(parsed == strlen(buf));
3679
-
3680
- buf = str;
3681
- size_t buflen = strlen(buf);
3682
-
3683
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3684
- if (parsed != buflen) {
3685
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN);
3686
- return;
3687
- }
3688
-
3689
- fprintf(stderr,
3690
- "\n*** Error expected but none in invalid header token test ***\n");
3691
- abort();
3692
- }
3693
-
3694
- void
3695
- test_invalid_header_field_token_error (int req)
3696
- {
3697
- test_invalid_header_field(req, "Fo@: Failure");
3698
- test_invalid_header_field(req, "Foo\01\test: Bar");
3699
- }
3700
-
3701
- void
3702
- test_double_content_length_error (int req)
3703
- {
3704
- http_parser parser;
3705
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3706
- size_t parsed;
3707
- const char *buf;
3708
- buf = req ?
3709
- "GET / HTTP/1.1\r\n" :
3710
- "HTTP/1.1 200 OK\r\n";
3711
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3712
- assert(parsed == strlen(buf));
3713
-
3714
- buf = "Content-Length: 0\r\nContent-Length: 1\r\n\r\n";
3715
- size_t buflen = strlen(buf);
3716
-
3717
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3718
- if (parsed != buflen) {
3719
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH);
3720
- return;
3721
- }
3722
-
3723
- fprintf(stderr,
3724
- "\n*** Error expected but none in double content-length test ***\n");
3725
- abort();
3726
- }
3727
-
3728
- void
3729
- test_chunked_content_length_error (int req)
3730
- {
3731
- http_parser parser;
3732
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3733
- size_t parsed;
3734
- const char *buf;
3735
- buf = req ?
3736
- "GET / HTTP/1.1\r\n" :
3737
- "HTTP/1.1 200 OK\r\n";
3738
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3739
- assert(parsed == strlen(buf));
3740
-
3741
- buf = "Transfer-Encoding: anything\r\nContent-Length: 1\r\n\r\n";
3742
- size_t buflen = strlen(buf);
3743
-
3744
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3745
- if (parsed != buflen) {
3746
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH);
3747
- return;
3748
- }
3749
-
3750
- fprintf(stderr,
3751
- "\n*** Error expected but none in chunked content-length test ***\n");
3752
- abort();
3753
- }
3754
-
3755
- void
3756
- test_header_cr_no_lf_error (int req)
3757
- {
3758
- http_parser parser;
3759
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3760
- size_t parsed;
3761
- const char *buf;
3762
- buf = req ?
3763
- "GET / HTTP/1.1\r\n" :
3764
- "HTTP/1.1 200 OK\r\n";
3765
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3766
- assert(parsed == strlen(buf));
3767
-
3768
- buf = "Foo: 1\rBar: 1\r\n\r\n";
3769
- size_t buflen = strlen(buf);
3770
-
3771
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3772
- if (parsed != buflen) {
3773
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_LF_EXPECTED);
3774
- return;
3775
- }
3776
-
3777
- fprintf(stderr,
3778
- "\n*** Error expected but none in header whitespace test ***\n");
3779
- abort();
3780
- }
3781
-
3782
- void
3783
- test_no_overflow_parse_url (void)
3784
- {
3785
- int rv;
3786
- struct http_parser_url u;
3787
-
3788
- http_parser_url_init(&u);
3789
- rv = http_parser_parse_url("http://example.com:8001", 22, 0, &u);
3790
-
3791
- if (rv != 0) {
3792
- fprintf(stderr,
3793
- "\n*** test_no_overflow_parse_url invalid return value=%d\n",
3794
- rv);
3795
- abort();
3796
- }
3797
-
3798
- if (u.port != 800) {
3799
- fprintf(stderr,
3800
- "\n*** test_no_overflow_parse_url invalid port number=%d\n",
3801
- u.port);
3802
- abort();
3803
- }
3804
- }
3805
-
3806
- void
3807
- test_header_overflow_error (int req)
3808
- {
3809
- http_parser parser;
3810
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3811
- size_t parsed;
3812
- const char *buf;
3813
- buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n";
3814
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3815
- assert(parsed == strlen(buf));
3816
-
3817
- buf = "header-key: header-value\r\n";
3818
- size_t buflen = strlen(buf);
3819
-
3820
- int i;
3821
- for (i = 0; i < 10000; i++) {
3822
- parsed = http_parser_execute(&parser, &settings_null, buf, buflen);
3823
- if (parsed != buflen) {
3824
- //fprintf(stderr, "error found on iter %d\n", i);
3825
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW);
3826
- return;
3827
- }
3828
- }
3829
-
3830
- fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n");
3831
- abort();
3832
- }
3833
-
3834
-
3835
- void
3836
- test_header_nread_value ()
3837
- {
3838
- http_parser parser;
3839
- http_parser_init(&parser, HTTP_REQUEST);
3840
- size_t parsed;
3841
- const char *buf;
3842
- buf = "GET / HTTP/1.1\r\nheader: value\nhdr: value\r\n";
3843
- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf));
3844
- assert(parsed == strlen(buf));
3845
-
3846
- assert(parser.nread == strlen(buf));
3847
- }
3848
-
3849
-
3850
- static void
3851
- test_content_length_overflow (const char *buf, size_t buflen, int expect_ok)
3852
- {
3853
- http_parser parser;
3854
- http_parser_init(&parser, HTTP_RESPONSE);
3855
- http_parser_execute(&parser, &settings_null, buf, buflen);
3856
-
3857
- if (expect_ok)
3858
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK);
3859
- else
3860
- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH);
3861
- }
3862
-
3863
- void
3864
- test_header_content_length_overflow_error (void)
3865
- {
3866
- #define X(size) \
3867
- "HTTP/1.1 200 OK\r\n" \
3868
- "Content-Length: " #size "\r\n" \
3869
- "\r\n"
3870
- const char a[] = X(1844674407370955160); /* 2^64 / 10 - 1 */
3871
- const char b[] = X(18446744073709551615); /* 2^64-1 */
3872
- const char c[] = X(18446744073709551616); /* 2^64 */
3873
- #undef X
3874
- test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */
3875
- test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */
3876
- test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */
3877
- }
3878
-
3879
- void
3880
- test_chunk_content_length_overflow_error (void)
3881
- {
3882
- #define X(size) \
3883
- "HTTP/1.1 200 OK\r\n" \
3884
- "Transfer-Encoding: chunked\r\n" \
3885
- "\r\n" \
3886
- #size "\r\n" \
3887
- "..."
3888
- const char a[] = X(FFFFFFFFFFFFFFE); /* 2^64 / 16 - 1 */
3889
- const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */
3890
- const char c[] = X(10000000000000000); /* 2^64 */
3891
- #undef X
3892
- test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */
3893
- test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */
3894
- test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */
3895
- }
3896
-
3897
- void
3898
- test_no_overflow_long_body (int req, size_t length)
3899
- {
3900
- http_parser parser;
3901
- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE);
3902
- size_t parsed;
3903
- size_t i;
3904
- char buf1[3000];
3905
- size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n",
3906
- req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length);
3907
- parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len);
3908
- if (parsed != buf1len)
3909
- goto err;
3910
-
3911
- for (i = 0; i < length; i++) {
3912
- char foo = 'a';
3913
- parsed = http_parser_execute(&parser, &settings_null, &foo, 1);
3914
- if (parsed != 1)
3915
- goto err;
3916
- }
3917
-
3918
- parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len);
3919
- if (parsed != buf1len) goto err;
3920
- return;
3921
-
3922
- err:
3923
- fprintf(stderr,
3924
- "\n*** error in test_no_overflow_long_body %s of length %lu ***\n",
3925
- req ? "REQUEST" : "RESPONSE",
3926
- (unsigned long)length);
3927
- abort();
3928
- }
3929
-
3930
- void
3931
- test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3)
3932
- {
3933
- int message_count = count_parsed_messages(3, r1, r2, r3);
3934
-
3935
- char total[ strlen(r1->raw)
3936
- + strlen(r2->raw)
3937
- + strlen(r3->raw)
3938
- + 1
3939
- ];
3940
- total[0] = '\0';
3941
-
3942
- strcat(total, r1->raw);
3943
- strcat(total, r2->raw);
3944
- strcat(total, r3->raw);
3945
-
3946
- parser_init(r1->type);
3947
-
3948
- size_t read;
3949
-
3950
- read = parse(total, strlen(total));
3951
-
3952
- if (parser.upgrade) {
3953
- upgrade_message_fix(total, read, 3, r1, r2, r3);
3954
- goto test;
3955
- }
3956
-
3957
- if (read != strlen(total)) {
3958
- print_error(total, read);
3959
- abort();
3960
- }
3961
-
3962
- read = parse(NULL, 0);
3963
-
3964
- if (read != 0) {
3965
- print_error(total, read);
3966
- abort();
3967
- }
3968
-
3969
- test:
3970
-
3971
- if (message_count != num_messages) {
3972
- fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages);
3973
- abort();
3974
- }
3975
-
3976
- if (!message_eq(0, 0, r1)) abort();
3977
- if (message_count > 1 && !message_eq(1, 0, r2)) abort();
3978
- if (message_count > 2 && !message_eq(2, 0, r3)) abort();
3979
- }
3980
-
3981
- /* SCAN through every possible breaking to make sure the
3982
- * parser can handle getting the content in any chunks that
3983
- * might come from the socket
3984
- */
3985
- void
3986
- test_scan (const struct message *r1, const struct message *r2, const struct message *r3)
3987
- {
3988
- char total[80*1024] = "\0";
3989
- char buf1[80*1024] = "\0";
3990
- char buf2[80*1024] = "\0";
3991
- char buf3[80*1024] = "\0";
3992
-
3993
- strcat(total, r1->raw);
3994
- strcat(total, r2->raw);
3995
- strcat(total, r3->raw);
3996
-
3997
- size_t read;
3998
-
3999
- int total_len = strlen(total);
4000
-
4001
- int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2;
4002
- int ops = 0 ;
4003
-
4004
- size_t buf1_len, buf2_len, buf3_len;
4005
- int message_count = count_parsed_messages(3, r1, r2, r3);
4006
-
4007
- int i,j,type_both;
4008
- for (type_both = 0; type_both < 2; type_both ++ ) {
4009
- for (j = 2; j < total_len; j ++ ) {
4010
- for (i = 1; i < j; i ++ ) {
4011
-
4012
- if (ops % 1000 == 0) {
4013
- printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops);
4014
- fflush(stdout);
4015
- }
4016
- ops += 1;
4017
-
4018
- parser_init(type_both ? HTTP_BOTH : r1->type);
4019
-
4020
- buf1_len = i;
4021
- strlncpy(buf1, sizeof(buf1), total, buf1_len);
4022
- buf1[buf1_len] = 0;
4023
-
4024
- buf2_len = j - i;
4025
- strlncpy(buf2, sizeof(buf1), total+i, buf2_len);
4026
- buf2[buf2_len] = 0;
4027
-
4028
- buf3_len = total_len - j;
4029
- strlncpy(buf3, sizeof(buf1), total+j, buf3_len);
4030
- buf3[buf3_len] = 0;
4031
-
4032
- assert(num_messages == 0);
4033
- messages[0].headers_complete_cb_called = FALSE;
4034
-
4035
- read = parse(buf1, buf1_len);
4036
-
4037
- if (!messages[0].headers_complete_cb_called && parser.nread != read) {
4038
- print_error(buf1, read);
4039
- goto error;
4040
- }
4041
-
4042
- if (parser.upgrade) goto test;
4043
-
4044
- if (read != buf1_len) {
4045
- print_error(buf1, read);
4046
- goto error;
4047
- }
4048
-
4049
- read += parse(buf2, buf2_len);
4050
-
4051
- if (parser.upgrade) goto test;
4052
-
4053
- if (read != buf1_len + buf2_len) {
4054
- print_error(buf2, read);
4055
- goto error;
4056
- }
4057
-
4058
- read += parse(buf3, buf3_len);
4059
-
4060
- if (parser.upgrade) goto test;
4061
-
4062
- if (read != buf1_len + buf2_len + buf3_len) {
4063
- print_error(buf3, read);
4064
- goto error;
4065
- }
4066
-
4067
- parse(NULL, 0);
4068
-
4069
- test:
4070
- if (parser.upgrade) {
4071
- upgrade_message_fix(total, read, 3, r1, r2, r3);
4072
- }
4073
-
4074
- if (message_count != num_messages) {
4075
- fprintf(stderr, "\n\nParser didn't see %d messages only %d\n",
4076
- message_count, num_messages);
4077
- goto error;
4078
- }
4079
-
4080
- if (!message_eq(0, 0, r1)) {
4081
- fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n");
4082
- goto error;
4083
- }
4084
-
4085
- if (message_count > 1 && !message_eq(1, 0, r2)) {
4086
- fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n");
4087
- goto error;
4088
- }
4089
-
4090
- if (message_count > 2 && !message_eq(2, 0, r3)) {
4091
- fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n");
4092
- goto error;
4093
- }
4094
- }
4095
- }
4096
- }
4097
- puts("\b\b\b\b100%");
4098
- return;
4099
-
4100
- error:
4101
- fprintf(stderr, "i=%d j=%d\n", i, j);
4102
- fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1);
4103
- fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2);
4104
- fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3);
4105
- abort();
4106
- }
4107
-
4108
- // user required to free the result
4109
- // string terminated by \0
4110
- char *
4111
- create_large_chunked_message (int body_size_in_kb, const char* headers)
4112
- {
4113
- int i;
4114
- size_t wrote = 0;
4115
- size_t headers_len = strlen(headers);
4116
- size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6;
4117
- char * buf = malloc(bufsize);
4118
-
4119
- memcpy(buf, headers, headers_len);
4120
- wrote += headers_len;
4121
-
4122
- for (i = 0; i < body_size_in_kb; i++) {
4123
- // write 1kb chunk into the body.
4124
- memcpy(buf + wrote, "400\r\n", 5);
4125
- wrote += 5;
4126
- memset(buf + wrote, 'C', 1024);
4127
- wrote += 1024;
4128
- strcpy(buf + wrote, "\r\n");
4129
- wrote += 2;
4130
- }
4131
-
4132
- memcpy(buf + wrote, "0\r\n\r\n", 6);
4133
- wrote += 6;
4134
- assert(wrote == bufsize);
4135
-
4136
- return buf;
4137
- }
4138
-
4139
- /* Verify that we can pause parsing at any of the bytes in the
4140
- * message and still get the result that we're expecting. */
4141
- void
4142
- test_message_pause (const struct message *msg)
4143
- {
4144
- char *buf = (char*) msg->raw;
4145
- size_t buflen = strlen(msg->raw);
4146
- size_t nread;
4147
-
4148
- parser_init(msg->type);
4149
-
4150
- do {
4151
- nread = parse_pause(buf, buflen);
4152
-
4153
- // We can only set the upgrade buffer once we've gotten our message
4154
- // completion callback.
4155
- if (messages[0].message_complete_cb_called &&
4156
- msg->upgrade &&
4157
- parser.upgrade) {
4158
- messages[0].upgrade = buf + nread;
4159
- goto test;
4160
- }
4161
-
4162
- if (nread < buflen) {
4163
-
4164
- // Not much do to if we failed a strict-mode check
4165
- if (HTTP_PARSER_ERRNO(&parser) == HPE_STRICT) {
4166
- return;
4167
- }
4168
-
4169
- assert (HTTP_PARSER_ERRNO(&parser) == HPE_PAUSED);
4170
- }
4171
-
4172
- buf += nread;
4173
- buflen -= nread;
4174
- http_parser_pause(&parser, 0);
4175
- } while (buflen > 0);
4176
-
4177
- nread = parse_pause(NULL, 0);
4178
- assert (nread == 0);
4179
-
4180
- test:
4181
- if (num_messages != 1) {
4182
- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name);
4183
- abort();
4184
- }
4185
-
4186
- if(!message_eq(0, 0, msg)) abort();
4187
- }
4188
-
4189
- /* Verify that body and next message won't be parsed in responses to CONNECT */
4190
- void
4191
- test_message_connect (const struct message *msg)
4192
- {
4193
- char *buf = (char*) msg->raw;
4194
- size_t buflen = strlen(msg->raw);
4195
-
4196
- parser_init(msg->type);
4197
-
4198
- parse_connect(buf, buflen);
4199
-
4200
- if (num_messages != 1) {
4201
- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name);
4202
- abort();
4203
- }
4204
-
4205
- if(!message_eq(0, 1, msg)) abort();
4206
- }
4207
-
4208
- int
4209
- main (void)
4210
- {
4211
- unsigned i, j, k;
4212
- unsigned long version;
4213
- unsigned major;
4214
- unsigned minor;
4215
- unsigned patch;
4216
-
4217
- version = http_parser_version();
4218
- major = (version >> 16) & 255;
4219
- minor = (version >> 8) & 255;
4220
- patch = version & 255;
4221
- printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version);
4222
-
4223
- printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser));
4224
- assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + sizeof(void *));
4225
-
4226
- //// API
4227
- test_preserve_data();
4228
- test_parse_url();
4229
- test_method_str();
4230
- test_status_str();
4231
-
4232
- //// NREAD
4233
- test_header_nread_value();
4234
-
4235
- //// OVERFLOW CONDITIONS
4236
- test_no_overflow_parse_url();
4237
-
4238
- test_header_overflow_error(HTTP_REQUEST);
4239
- test_no_overflow_long_body(HTTP_REQUEST, 1000);
4240
- test_no_overflow_long_body(HTTP_REQUEST, 100000);
4241
-
4242
- test_header_overflow_error(HTTP_RESPONSE);
4243
- test_no_overflow_long_body(HTTP_RESPONSE, 1000);
4244
- test_no_overflow_long_body(HTTP_RESPONSE, 100000);
4245
-
4246
- test_header_content_length_overflow_error();
4247
- test_chunk_content_length_overflow_error();
4248
-
4249
- //// HEADER FIELD CONDITIONS
4250
- test_double_content_length_error(HTTP_REQUEST);
4251
- test_chunked_content_length_error(HTTP_REQUEST);
4252
- test_header_cr_no_lf_error(HTTP_REQUEST);
4253
- test_invalid_header_field_token_error(HTTP_REQUEST);
4254
- test_invalid_header_field_content_error(HTTP_REQUEST);
4255
- test_double_content_length_error(HTTP_RESPONSE);
4256
- test_chunked_content_length_error(HTTP_RESPONSE);
4257
- test_header_cr_no_lf_error(HTTP_RESPONSE);
4258
- test_invalid_header_field_token_error(HTTP_RESPONSE);
4259
- test_invalid_header_field_content_error(HTTP_RESPONSE);
4260
-
4261
- test_simple_type(
4262
- "POST / HTTP/1.1\r\n"
4263
- "Content-Length:\r\n" // empty
4264
- "\r\n",
4265
- HPE_INVALID_CONTENT_LENGTH,
4266
- HTTP_REQUEST);
4267
-
4268
- test_simple_type(
4269
- "POST / HTTP/1.1\r\n"
4270
- "Content-Length: 42 \r\n" // Note the surrounding whitespace.
4271
- "\r\n",
4272
- HPE_OK,
4273
- HTTP_REQUEST);
4274
-
4275
- test_simple_type(
4276
- "POST / HTTP/1.1\r\n"
4277
- "Content-Length: 4 2\r\n"
4278
- "\r\n",
4279
- HPE_INVALID_CONTENT_LENGTH,
4280
- HTTP_REQUEST);
4281
-
4282
- test_simple_type(
4283
- "POST / HTTP/1.1\r\n"
4284
- "Content-Length: 13 37\r\n"
4285
- "\r\n",
4286
- HPE_INVALID_CONTENT_LENGTH,
4287
- HTTP_REQUEST);
4288
-
4289
- test_simple_type(
4290
- "POST / HTTP/1.1\r\n"
4291
- "Content-Length: 42\r\n"
4292
- " Hello world!\r\n",
4293
- HPE_INVALID_CONTENT_LENGTH,
4294
- HTTP_REQUEST);
4295
-
4296
- test_simple_type(
4297
- "POST / HTTP/1.1\r\n"
4298
- "Content-Length: 42\r\n"
4299
- " \r\n",
4300
- HPE_OK,
4301
- HTTP_REQUEST);
4302
-
4303
- //// RESPONSES
4304
-
4305
- test_simple_type("HTP/1.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4306
- test_simple_type("HTTP/01.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4307
- test_simple_type("HTTP/11.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4308
- test_simple_type("HTTP/1.01 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4309
- test_simple_type("HTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4310
- test_simple_type("\rHTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
4311
-
4312
- for (i = 0; i < ARRAY_SIZE(responses); i++) {
4313
- test_message(&responses[i]);
4314
- }
4315
-
4316
- for (i = 0; i < ARRAY_SIZE(responses); i++) {
4317
- test_message_pause(&responses[i]);
4318
- }
4319
-
4320
- for (i = 0; i < ARRAY_SIZE(responses); i++) {
4321
- test_message_connect(&responses[i]);
4322
- }
4323
-
4324
- for (i = 0; i < ARRAY_SIZE(responses); i++) {
4325
- if (!responses[i].should_keep_alive) continue;
4326
- for (j = 0; j < ARRAY_SIZE(responses); j++) {
4327
- if (!responses[j].should_keep_alive) continue;
4328
- for (k = 0; k < ARRAY_SIZE(responses); k++) {
4329
- test_multiple3(&responses[i], &responses[j], &responses[k]);
4330
- }
4331
- }
4332
- }
4333
-
4334
- test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]);
4335
- test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]);
4336
-
4337
- // test very large chunked response
4338
- {
4339
- char * msg = create_large_chunked_message(31337,
4340
- "HTTP/1.0 200 OK\r\n"
4341
- "Transfer-Encoding: chunked\r\n"
4342
- "Content-Type: text/plain\r\n"
4343
- "\r\n");
4344
- struct message large_chunked =
4345
- {.name= "large chunked"
4346
- ,.type= HTTP_RESPONSE
4347
- ,.raw= msg
4348
- ,.should_keep_alive= FALSE
4349
- ,.message_complete_on_eof= FALSE
4350
- ,.http_major= 1
4351
- ,.http_minor= 0
4352
- ,.status_code= 200
4353
- ,.response_status= "OK"
4354
- ,.num_headers= 2
4355
- ,.headers=
4356
- { { "Transfer-Encoding", "chunked" }
4357
- , { "Content-Type", "text/plain" }
4358
- }
4359
- ,.body_size= 31337*1024
4360
- ,.num_chunks_complete= 31338
4361
- };
4362
- for (i = 0; i < MAX_CHUNKS; i++) {
4363
- large_chunked.chunk_lengths[i] = 1024;
4364
- }
4365
- test_message_count_body(&large_chunked);
4366
- free(msg);
4367
- }
4368
-
4369
-
4370
-
4371
- printf("response scan 1/2 ");
4372
- test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY]
4373
- , &responses[NO_BODY_HTTP10_KA_204]
4374
- , &responses[NO_REASON_PHRASE]
4375
- );
4376
-
4377
- printf("response scan 2/2 ");
4378
- test_scan( &responses[BONJOUR_MADAME_FR]
4379
- , &responses[UNDERSTORE_HEADER_KEY]
4380
- , &responses[NO_CARRIAGE_RET]
4381
- );
4382
-
4383
- puts("responses okay");
4384
-
4385
-
4386
- /// REQUESTS
4387
-
4388
- test_simple("GET / IHTTP/1.0\r\n\r\n", HPE_INVALID_CONSTANT);
4389
- test_simple("GET / ICE/1.0\r\n\r\n", HPE_INVALID_CONSTANT);
4390
- test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION);
4391
- test_simple("GET / HTTP/01.1\r\n\r\n", HPE_INVALID_VERSION);
4392
- test_simple("GET / HTTP/11.1\r\n\r\n", HPE_INVALID_VERSION);
4393
- test_simple("GET / HTTP/1.01\r\n\r\n", HPE_INVALID_VERSION);
4394
-
4395
- test_simple("GET / HTTP/1.0\r\nHello: w\1rld\r\n\r\n", HPE_INVALID_HEADER_TOKEN);
4396
- test_simple("GET / HTTP/1.0\r\nHello: woooo\2rld\r\n\r\n", HPE_INVALID_HEADER_TOKEN);
4397
-
4398
- // Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js
4399
- test_simple("GET / HTTP/1.1\r\n"
4400
- "Test: Düsseldorf\r\n",
4401
- HPE_OK);
4402
-
4403
- // Well-formed but incomplete
4404
- test_simple("GET / HTTP/1.1\r\n"
4405
- "Content-Type: text/plain\r\n"
4406
- "Content-Length: 6\r\n"
4407
- "\r\n"
4408
- "fooba",
4409
- HPE_OK);
4410
-
4411
- // Unknown Transfer-Encoding in request
4412
- test_simple("GET / HTTP/1.1\r\n"
4413
- "Transfer-Encoding: unknown\r\n"
4414
- "\r\n",
4415
- HPE_INVALID_TRANSFER_ENCODING);
4416
-
4417
- static const char *all_methods[] = {
4418
- "DELETE",
4419
- "GET",
4420
- "HEAD",
4421
- "POST",
4422
- "PUT",
4423
- //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel
4424
- "OPTIONS",
4425
- "TRACE",
4426
- "COPY",
4427
- "LOCK",
4428
- "MKCOL",
4429
- "MOVE",
4430
- "PROPFIND",
4431
- "PROPPATCH",
4432
- "SEARCH",
4433
- "UNLOCK",
4434
- "BIND",
4435
- "REBIND",
4436
- "UNBIND",
4437
- "ACL",
4438
- "REPORT",
4439
- "MKACTIVITY",
4440
- "CHECKOUT",
4441
- "MERGE",
4442
- "M-SEARCH",
4443
- "NOTIFY",
4444
- "SUBSCRIBE",
4445
- "UNSUBSCRIBE",
4446
- "PATCH",
4447
- "PURGE",
4448
- "MKCALENDAR",
4449
- "LINK",
4450
- "UNLINK",
4451
- 0 };
4452
- const char **this_method;
4453
- for (this_method = all_methods; *this_method; this_method++) {
4454
- char buf[200];
4455
- sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method);
4456
- test_simple(buf, HPE_OK);
4457
- }
4458
-
4459
- static const char *bad_methods[] = {
4460
- "ASDF",
4461
- "C******",
4462
- "COLA",
4463
- "GEM",
4464
- "GETA",
4465
- "M****",
4466
- "MKCOLA",
4467
- "PROPPATCHA",
4468
- "PUN",
4469
- "PX",
4470
- "SA",
4471
- "hello world",
4472
- 0 };
4473
- for (this_method = bad_methods; *this_method; this_method++) {
4474
- char buf[200];
4475
- sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method);
4476
- test_simple(buf, HPE_INVALID_METHOD);
4477
- }
4478
-
4479
- // illegal header field name line folding
4480
- test_simple("GET / HTTP/1.1\r\n"
4481
- "name\r\n"
4482
- " : value\r\n"
4483
- "\r\n",
4484
- HPE_INVALID_HEADER_TOKEN);
4485
-
4486
- const char *dumbluck2 =
4487
- "GET / HTTP/1.1\r\n"
4488
- "X-SSL-Nonsense: -----BEGIN CERTIFICATE-----\r\n"
4489
- "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n"
4490
- "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n"
4491
- "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n"
4492
- "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n"
4493
- "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n"
4494
- "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n"
4495
- "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n"
4496
- "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n"
4497
- "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n"
4498
- "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n"
4499
- "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n"
4500
- "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n"
4501
- "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n"
4502
- "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n"
4503
- "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n"
4504
- "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n"
4505
- "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n"
4506
- "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n"
4507
- "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n"
4508
- "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n"
4509
- "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n"
4510
- "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n"
4511
- "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n"
4512
- "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n"
4513
- "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n"
4514
- "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n"
4515
- "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n"
4516
- "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n"
4517
- "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n"
4518
- "\tRA==\r\n"
4519
- "\t-----END CERTIFICATE-----\r\n"
4520
- "\r\n";
4521
- test_simple(dumbluck2, HPE_OK);
4522
-
4523
- const char *corrupted_connection =
4524
- "GET / HTTP/1.1\r\n"
4525
- "Host: www.example.com\r\n"
4526
- "Connection\r\033\065\325eep-Alive\r\n"
4527
- "Accept-Encoding: gzip\r\n"
4528
- "\r\n";
4529
- test_simple(corrupted_connection, HPE_INVALID_HEADER_TOKEN);
4530
-
4531
- const char *corrupted_header_name =
4532
- "GET / HTTP/1.1\r\n"
4533
- "Host: www.example.com\r\n"
4534
- "X-Some-Header\r\033\065\325eep-Alive\r\n"
4535
- "Accept-Encoding: gzip\r\n"
4536
- "\r\n";
4537
- test_simple(corrupted_header_name, HPE_INVALID_HEADER_TOKEN);
4538
-
4539
- #if 0
4540
- // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body
4541
- // until EOF.
4542
- //
4543
- // no content-length
4544
- // error if there is a body without content length
4545
- const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n"
4546
- "Accept: */*\r\n"
4547
- "\r\n"
4548
- "HELLO";
4549
- test_simple(bad_get_no_headers_no_body, 0);
4550
- #endif
4551
- /* TODO sending junk and large headers gets rejected */
4552
-
4553
-
4554
- /* check to make sure our predefined requests are okay */
4555
- for (i = 0; i < ARRAY_SIZE(requests); i++) {
4556
- test_message(&requests[i]);
4557
- }
4558
-
4559
- for (i = 0; i < ARRAY_SIZE(requests); i++) {
4560
- test_message_pause(&requests[i]);
4561
- }
4562
-
4563
- for (i = 0; i < ARRAY_SIZE(requests); i++) {
4564
- if (!requests[i].should_keep_alive) continue;
4565
- for (j = 0; j < ARRAY_SIZE(requests); j++) {
4566
- if (!requests[j].should_keep_alive) continue;
4567
- for (k = 0; k < ARRAY_SIZE(requests); k++) {
4568
- test_multiple3(&requests[i], &requests[j], &requests[k]);
4569
- }
4570
- }
4571
- }
4572
-
4573
- printf("request scan 1/4 ");
4574
- test_scan( &requests[GET_NO_HEADERS_NO_BODY]
4575
- , &requests[GET_ONE_HEADER_NO_BODY]
4576
- , &requests[GET_NO_HEADERS_NO_BODY]
4577
- );
4578
-
4579
- printf("request scan 2/4 ");
4580
- test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE]
4581
- , &requests[POST_IDENTITY_BODY_WORLD]
4582
- , &requests[GET_FUNKY_CONTENT_LENGTH]
4583
- );
4584
-
4585
- printf("request scan 3/4 ");
4586
- test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END]
4587
- , &requests[CHUNKED_W_TRAILING_HEADERS]
4588
- , &requests[CHUNKED_W_NONSENSE_AFTER_LENGTH]
4589
- );
4590
-
4591
- printf("request scan 4/4 ");
4592
- test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET]
4593
- , &requests[PREFIX_NEWLINE_GET ]
4594
- , &requests[CONNECT_REQUEST]
4595
- );
4596
-
4597
- puts("requests okay");
4598
-
4599
- return 0;
4600
- }