diff --git a/ocaml/_tags b/ocaml/_tags index 24d0324..e94382e 100644 --- a/ocaml/_tags +++ b/ocaml/_tags @@ -1,3 +1,3 @@ -true: package(netclient), package(netstring) +true: package(netclient), package(netstring), package(nettls-gnutls) : package(oUnit) : package(irc-client.lwt) diff --git a/ocaml/simpleHttp.ml b/ocaml/simpleHttp.ml index 83971c9..58d3363 100644 --- a/ocaml/simpleHttp.ml +++ b/ocaml/simpleHttp.ml @@ -4,6 +4,8 @@ open Nethtml open Netencoding;; +Nettls_gnutls.init();; + let extract_string_value document = match document with | Data(s) -> Some s diff --git a/ocaml/test.ml b/ocaml/test.ml index 139c592..8bd6caa 100644 --- a/ocaml/test.ml +++ b/ocaml/test.ml @@ -33,12 +33,20 @@ let test_escape_characters text_ctx = assert_equal expected (SimpleHttp.decode_esc_char html_str) +let test_https test_ctx = + let url = "https://en.wikipedia.org/wiki/Main_Page" in + let title = SimpleHttp.get_http_title (SimpleHttp.get_body url) in + assert_equal (Some "Wikipedia, the free encyclopedia") title + (* Name the test cases and group them together *) let suite = "suite">::: - ["test get_title">:: test_get_title; - "test remove_spaces">:: test_remove_spaces; - "test HTML character escaping">:: test_escape_characters] + [ + "test get_title">:: test_get_title; + "test remove_spaces">:: test_remove_spaces; + "test HTML character escaping">:: test_escape_characters; + "test HTTPS">:: test_https + ] let () = run_test_tt_main suite