Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
smallhadroncollider committed Jan 18, 2019
2 parents 6184c61 + 8ece682 commit 37a4d11
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: brok
version: 0.1.1.0
version: 0.1.2.0
github: "smallhadroncollider/brok"
license: BSD3
author: "Small Hadron Collider"
Expand Down
6 changes: 2 additions & 4 deletions src/Brok/IO/Http.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ makeRequest delay method url =

tryWithGet :: Integer -> URL -> StatusCode -> IO StatusCode
tryWithGet delay url (Right code)
-- various 400/500 errors mean HEAD support doesn't work
-- so try with GET instead
| code >= 400 && code /= 404 = makeRequest delay "GET" url
| code >= 400 = makeRequest delay "GET" url
| otherwise = return (Right code)
tryWithGet _ _ sc = return sc
tryWithGet delay url (Left _) = makeRequest delay "GET" url

fetch :: Integer -> URL -> IO StatusCode
fetch delay url =
Expand Down
8 changes: 5 additions & 3 deletions taskell.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
## Refactoring


## Features

- Should detect if internet connection is down
- Cache length option should accept units: s, m, h, d - default to s
- Should be able to detect links without http:// or https:// prefixes
- More detailed HttpException errors
- Parallel HTTP fetch for separate domains

## Bugs

- Is an invalid URL an error?
> Should an invalid URL count as an error? The parser shouldn't really pick up invalid URLs. But if it looks like one and fails then it is probably worth high-lighting.
- Can't parse links containing single quote marks
- Fetching message sometimes goes to more than one line, so next line doesn't replace it (saveCursor/restoreCursor?)
- Checks the same URL multiple times if in different files
- Edge case: shouldn't delay if only a single URL being checked

## In Progress
Expand All @@ -33,3 +34,4 @@
- Use attoparsec
> Already used by HTTP-conduit, so may as well use it
- Fixed InvalidURLException crash
- Fixed issue with HEAD request returning a 404
11 changes: 11 additions & 0 deletions test/IO/HttpTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ test_http =
"https://code.tutsplus.com/tutorials/stateful-vs-stateless-functional-components-in-react--cms-29541"
(Working 200))
result
, testCase "Random blog (404 on a HEAD request)" $ do
result <-
check 0 $
urlToLink
"https://blog.infinitenegativeutility.com/2017/12/some-notes-about-how-i-write-haskell"
assertEqual
"Returns a 200"
(Link
"https://blog.infinitenegativeutility.com/2017/12/some-notes-about-how-i-write-haskell"
(Working 200))
result
, testCase "Non-existant site" $ do
result <- check 0 $ urlToLink "http://askdjfhaksjdhfkajsdfh.com"
assertEqual
Expand Down

0 comments on commit 37a4d11

Please sign in to comment.