Skip to content
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

Chunked Encoding doesn't work yet #3

Open
uwap opened this issue Aug 23, 2015 · 2 comments
Open

Chunked Encoding doesn't work yet #3

uwap opened this issue Aug 23, 2015 · 2 comments

Comments

@uwap
Copy link
Owner

uwap commented Aug 23, 2015

When it comes to transfer encodings idris-http lacks a lot of features. Chunked Encoding is a special case that needs special review. With chunked encoding we are bound to counting bytes. The String type doesn't have the ability to check a length in bytes. That is a huge problem.

Idea 1: ByteString
We could just start making a ByteString library to support it. We would have one large problem with it: We would need to get TCP libraries to use them. Then chunked encoding wouldn't be too much magic here.

Idea 2: Do awkward requests
We could start reqeusting single bytes over TCP and then finally when we get to chunked encoding we request the nujmber of bytes of the next chunk. This is an awful implementation that I wouldn't like to support.

Are there any other ways to go?

@uwap uwap added this to the 0.1 Release milestone Oct 11, 2015
@uwap uwap closed this as completed in a890f1f Nov 22, 2016
@hackle
Copy link

hackle commented Dec 26, 2018

Hi - I used idris-http for a bit of play and found chunked encoding is not working as expected, because the current hexParser might not return the correct number, Try the below if ever needed:

hexParser : Parser Int
hexParser = do { x <- hexParser'; pure $ fst x } where
  hexParser' : Parser (Int, Int)
  hexParser' = do
    c <- hexDigit
    hex2 <- opt $ hexParser'
    let hex = ord $ toUpper c
    let num = if hex >= ord '0' && hex <= ord '9'
                 then hex - ord '0'
                 else 10 + hex - ord 'A'
    case hex2 of
         Just (x, pw) =>
            let pw' = pw + 1;
                mag = Prelude.pow 16 $ cast {to=Nat} pw' in
                pure (x + num * mag, pw')
         Nothing => pure (num, 0)

With current hexParser:

hexParser' : Int -> Parser Int

*Parsers> parse hexParser "A0"
Right 0 : Either String Int

Sorry I should have started a PR couldn't at this moment so think it's best to report the issue first.

@uwap uwap reopened this Dec 26, 2018
@uwap
Copy link
Owner Author

uwap commented Dec 26, 2018

@hackle thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants