<commit_before>{-# LANGUAGE OverloadedStrings #-}

module Main where

import Data.ByteString.Char8 (unpack)
import Control.Exception (catch)
import Control.Monad (when)
import System.Environment (getArgs, getProgName)
import System.Exit (exitSuccess, exitFailure)

import Network.Wreq
import Control.Lens ((^.))
import Network.HTTP.Client (HttpException(TlsExceptionHostPort))

main :: IO ()
main = do
  args <- getArgs
  let argc = length args
  when (argc /= 2 && argc /= 3) $ do
    prog <- getProgName
    putStrLn $ prog ++ " <host> <port> [ca-bundle]"
    exitFailure

  when (argc == 3) $ do
    putStrLn "UNSUPPORTED"
    exitSuccess

  let host = args !! 0
      port = args !! 1

  catch
    (doGet $ "https://" ++ host ++ ":" ++ port)
    (\exception -> do
        let (TlsExceptionHostPort e _ _) = exception
        putStrLn (show e)
        putStrLn "VERIFY FAILURE"
        exitSuccess
    )
  where
    doGet :: String -> IO ()
    doGet url = do
      r <- get url
      let code = r ^. responseStatus . statusCode
          msg  = r ^. responseStatus . statusMessage
      putStrLn (show code ++" "++ unpack msg)
      putStrLn "VERIFY SUCCESS"
      exitSuccess<commit_msg>haskell-wreq: remove unneccessary let and show<commit_after>{-# LANGUAGE OverloadedStrings #-}

module Main where

import Data.ByteString.Char8 (unpack)
import Control.Exception (catch)
import Control.Monad (when)
import System.Environment (getArgs, getProgName)
import System.Exit (exitSuccess, exitFailure)

import Network.Wreq
import Control.Lens ((^.))
import Network.HTTP.Client (HttpException(TlsExceptionHostPort))

main :: IO ()
main = do
  args <- getArgs
  let argc = length args
  when (argc /= 2 && argc /= 3) $ do
    prog <- getProgName
    putStrLn $ prog ++ " <host> <port> [ca-bundle]"
    exitFailure

  when (argc == 3) $ do
    putStrLn "UNSUPPORTED"
    exitSuccess

  let host = args !! 0
      port = args !! 1

  catch
    (doGet $ "https://" ++ host ++ ":" ++ port)
    (\(TlsExceptionHostPort e _ _) -> do
        print e
        putStrLn "VERIFY FAILURE"
        exitSuccess
    )
  where
    doGet :: String -> IO ()
    doGet url = do
      r <- get url
      let code = r ^. responseStatus . statusCode
          msg  = r ^. responseStatus . statusMessage
      putStrLn (show code ++" "++ unpack msg)
      putStrLn "VERIFY SUCCESS"
      exitSuccess
{'fraction_non_alphanumeric': 0.11841550779603877, 'fraction_numerical': 0.0050568900126422255, 'mean_word_length': 2.686335403726708, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6515683', 'n_tokens_mistral': 799, 'n_tokens_neox': 767, 'n_words': 228}