-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated Network usage #25
Merged
parsonsmatt
merged 5 commits into
jhickner:master
from
plow-technologies:shulhi-ghc86-upgrade
Jun 19, 2019
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd29910
Add network-bsd
shulhi 31a4fd7
Replace deprecated Network usage
shulhi ab400d8
Fix crlf and indentations
shulhi cb3da1f
Read buffer till empty instead of reading lines with max bytes
shulhi 91eed69
Use connectionGetLine and deprecate redundant functions
shulhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,8 +137,14 @@ parseResponse conn = do | |
(code, bdy) <- readLines | ||
return (read $ B8.unpack code, B8.unlines bdy) | ||
where | ||
getLines c acc = do | ||
res <- Conn.connectionGetChunk c | ||
if B8.null res | ||
then return acc | ||
else getLines c $ B8.append acc res | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This current implementation does not return a line, but instead returns the entire contents of the connection. Replacing it with |
||
|
||
readLines = do | ||
l <- Conn.connectionGetLine (16 * 1024) conn | ||
l <- getLines conn B8.empty | ||
let (c, bdy) = B8.span isDigit l | ||
if not (B8.null bdy) && B8.head bdy == '-' | ||
then do (c2, ls) <- readLines | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parsonsmatt I need some help with this as I am not sure if this is right or should I just stick with
connectionGetLine
. Having to specify max bytes per line seems a little off to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking out loud here:
B8.hGetLine :: Handle -> IO ByteString
. Implementation linked.\n
character or the end-of-file. (figuring this out exactly took me a long time, dang the bytestring internals are tough)connectionGetLine
doesn't work in exactly the same way. TheInt
parameter is to prevent DoS attacks, so it'd be a security improvement to have it for sure - no idea what typical line length limit might be safe here 🤷♂️ .connectionGetLine
is that it throwsisEOFError
exception on end of input. Except, it says "An end of file will be considered as a line terminator too, if line is not empty." - Looking at the source... well, it's a bit confusing, but I think I've worked out what is going on.I think we're fine with
connectionGetLine
, we just need to pick a suitable line length.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick Google and got this StackOverflow post re line lengths in mail.
I think 1000 is a reasonable pick. The standard says lines
MUST
be no more than 998 characters.