Last active
December 5, 2022 07:57
-
-
Save tatac1/000ec3ba7530754ad556 to your computer and use it in GitHub Desktop.
error message when use proxy.. "*** Exception: Network/HTTP/Client/Manager.hs:(334,9)-(336,45): Non-exhaustive patterns in case"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Network.Connection (TLSSettings (..)) | |
| import Network.HTTP.Conduit | |
| import Network.HTTP.Types.Status | |
| import qualified Data.ByteString.Char8 as B | |
| import qualified Data.Text as T | |
| import Data.Time.Clock | |
| import Data.Time.Calendar | |
| import qualified Control.Exception as E | |
| import qualified Data.ByteString.Lazy as L | |
| past :: UTCTime | |
| past = UTCTime (ModifiedJulianDay 56200) (secondsToDiffTime 0) | |
| future :: UTCTime | |
| future = UTCTime (ModifiedJulianDay 562000) (secondsToDiffTime 0) | |
| cookie :: Cookie | |
| cookie = Cookie { cookie_name = "password_hash" | |
| , cookie_value = "abf472c35f8297fbcabf2911230001234fd2" | |
| , cookie_expiry_time = future | |
| , cookie_domain = "vul.jp" | |
| , cookie_path = "/" | |
| , cookie_creation_time = past | |
| , cookie_last_access_time = past | |
| , cookie_persistent = False | |
| , cookie_host_only = False | |
| , cookie_secure_only = False | |
| , cookie_http_only = False | |
| } | |
| getSomething :: IO L.ByteString | |
| getSomething = do | |
| let url = "https://vul.jp/" | |
| request' <- parseUrl url | |
| let settings = mkManagerSettings (TLSSettingsSimple True False False) Nothing | |
| let request = request' | |
| { cookieJar = Just $ createCookieJar [cookie] | |
| , method = "POST" | |
| , secure = True | |
| } | |
| let req = addProxy "localhost" 10000 request | |
| eitherResp <- E.try (withManagerSettings settings $ httpLbs req) | |
| case eitherResp of | |
| Left (StatusCodeException s _ _) | |
| | statusCode s == 403 -> return "login failed." | |
| | statusCode s == 404 -> return "Dose not exist." | |
| | otherwise -> return "" | |
| Right resp -> return (responseBody resp) | |
| main = do | |
| body <- getSomething | |
| print body |
tatac1
commented
May 16, 2014
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment