<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Network.HTTP.Dispatch.Examples.RequestExamples where

import           Network.HTTP.Dispatch.Core
import           Network.HTTP.Dispatch.Headers as Headers
import           Network.HTTP.Dispatch.Types

-- | Make a simple GET request
--
getRequestExample :: IO HTTPResponse
getRequestExample = runRequest $ get "https://httpbin.org/get"

-- | Get the response code from a request
--
responseCodeExample :: IO Int
responseCodeExample = do
  -- Run the request
  response <- runRequest (get "https://httpbin.org/get")
  -- Get the response code
  let code = respStatus response
  -- Return it
  return $ code

-- | Construct a GET request with added HTTP headers
--
getRequestWithHeadersExample :: HTTPRequest
getRequestWithHeadersExample =
    withHeaders (get "https://httpbin.org/get") [jsonHeader]
      where jsonHeader = header "Content-Type" "application/json"
<commit_msg>Update RequestExamples.hs<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Network.HTTP.Dispatch.Examples.RequestExamples where

import           Network.HTTP.Dispatch.Core
import           Network.HTTP.Dispatch.Headers as Headers
import           Network.HTTP.Dispatch.Types

-- | Make a simple GET request
--
getRequestExample :: IO HTTPResponse
getRequestExample = runRequest $ get "https://httpbin.org/get"

-- | Get the response code from a request
--
responseCodeExample :: IO Int
responseCodeExample = do
  -- Run the request
  response <- runRequest (get "https://httpbin.org/get")
  -- Get the response code
  let code = respStatus response
  -- Return it
  return code

-- | Construct a GET request with added HTTP headers
--
getRequestWithHeadersExample :: HTTPRequest
getRequestWithHeadersExample =
    withHeaders (get "https://httpbin.org/get") [jsonHeader]
      where jsonHeader = header "Content-Type" "application/json"

{'fraction_non_alphanumeric': 0.09691160809371673, 'fraction_numerical': 0.0, 'mean_word_length': 3.5606796116504853, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '368308', 'n_tokens_mistral': 507, 'n_tokens_neox': 499, 'n_words': 155}