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

[wip] testing chunked transfer encoding #15

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

jarlah
Copy link
Collaborator

@jarlah jarlah commented Nov 24, 2024

pack repl src/Test.idr 
Test> :exec silly_me
MkHttpResponse {status_code = (200 ** OK), status_name = "OK", headers = [("Content-Type", "text/html"), ("Date", "Sun, 24 Nov 2024 07:44:46 GMT"), ("Server", "Microsoft-IIS/10.0"), ("Cache-Control", "private"), ("Set-Cookie", "ARRAffinity=5c3b3eeb308eb53980891741456831fd17b082f53c89f03c9c9dcc2d905209a3;Path=/;HttpOnly;Secure;Domain=anglesharp.azurewebsites.net"), ("Set-Cookie", "ARRAffinitySameSite=5c3b3eeb308eb53980891741456831fd17b082f53c89f03c9c9dcc2d905209a3;Path=/;HttpOnly;SameSite=None;Secure;Domain=anglesharp.azurewebsites.net"), ("Transfer-Encoding", "chunked"), ("X-AspNetMvc-Version", "5.0"), ("X-AspNet-Version", "4.0.30319"), ("X-Powered-By", "ASP.NET")]}
Asking for data
Asked for data
got [60, 33, 68, 79, 67, 84, 89, 80, 69, 32, 104, 116, 109, 108, 62, 13, 10, 60, 104, 116, 109, 108, 32, 108, 97, 110, 103, 61, 101, 110, 62, 13, 10, 60, 104, 101, 97, 100, 62, 13, 10, 60, 109, 101, 116, 97, 32, 99, 104, 97, 114, 115, 101, 116, 61, 39, 117, 116, 102, 45, 56, 39, 62, 13, 10, 60, 116, 105, 116, 108, 101, 62, 67, 104, 117, 110, 107, 101, 100, 32, 116, 114, 97, 110, 115, 102, 101, 114, 32, 101, 110, 99, 111, 100, 105, 110, 103, 32, 116, 101, 115, 116, 60, 47, 116, 105, 116, 108, 101, 62, 13, 10, 60, 47, 104, 101, 97, 100, 62, 13, 10, 60, 98, 111, 100, 121, 62]
Asking for data
.... hangs forever and ever and ever ...

the bytes is this

<!DOCTYPE html>
<html lang=en>
<head>
<meta charset='utf-8'>
<title>Chunked transfer encoding test</title>
</head>
<body>

@jarlah jarlah marked this pull request as draft November 24, 2024 07:53
@jarlah
Copy link
Collaborator Author

jarlah commented Nov 24, 2024

could be we need to redesign this start_request function to create new channels for each call to channel_to_stream? i dont know. Throwing darts in the dark here.

start_request : {m, e : _} -> (HasIO m, Scheduler e m scheduler) =>
          scheduler ->
          Protocol ->
          RawHttpMessage ->
          Stream (Of Bits8) m (Either e ()) ->
          m (Either (HttpError e) (HttpResponse, Stream (Of Bits8) m (Either (HttpError e) ())))
start_request scheduler protocol msg content = do
  mvar <- makeChannel
  schedule_request scheduler protocol $ MkScheduleRequest msg content mvar
  Right response <- channelGet mvar
  | Left err => pure $ Left err
  let (encoding ** wit) = decompressor $ to_list $ lookup_header response.raw_http_response.headers ContentEncoding
  pure $ Right (response.raw_http_response, channel_to_stream (init @{wit}) response.content)

step one should be to understand "whats a channel"... (for me i mean)

@jarlah
Copy link
Collaborator Author

jarlah commented Nov 24, 2024

so response is response : ScheduleResponse e m
and response.content is Network.HTTP.Scheduler.ScheduleResponse.(.content) : ScheduleResponse e m -> Channel (Either (HttpError e) (Maybe (List Bits8)))
so what we get into channel_to_stream is indeed a channel, but from ScheduleResponse

@jarlah
Copy link
Collaborator Author

jarlah commented Nov 24, 2024

tied into scheme backend code ..

||| Concurrency primitives, e.g. threads, mutexes, etc.
|||
||| N.B.: At the moment this is pretty fundamentally tied to the Scheme RTS.
||| Given that different back ends will have entirely different threading
||| models, it might be unavoidable, but we might want to think about possible
||| primitives that back ends should support.
module System.Concurrency

@jarlah
Copy link
Collaborator Author

jarlah commented Dec 11, 2024

@Matthew-Mosior naive approach here .. trying to use the new with timeout function .. but we really need to make some type aliases here .. its impossible to read what it gets and what it wants and to see the diff clearly. Especially for me :D

diff for what i added here

https://github.com/idris-community/idris2-http/pull/15/files#diff-a4b68fc667ac43a17d0832e94cece61d3e493fc6ff08a9394aece9323d44847eR75

error when building

╰─ pack build
[ info ] Found local config at /home/jarlah/projects/idris2-http/pack.toml
[ info ] Using package collection nightly-241210
[ build ] 24/31: Building Network.HTTP.Scheduler (src/Network/HTTP/Scheduler.idr)
[ build ] Error: While processing right hand side of start_request. When unifying:
[ build ] Either (HttpError e) ?b
[ build ] and:
[ build ] m (Either (HttpError e) (HttpResponse, Stream (Of Bits8) m (Either (HttpError e) ())))
[ build ] Mismatch between: Either (HttpError e) ?b and m (Either (HttpError e) (HttpResponse, Stream (Of Bits8) m (Either (HttpError e) ()))).
[ build ]
[ build ] Network.HTTP.Scheduler:80:3--81:32
[ build ] 80 | Right response <- res
[ build ] 81 | | Left err => pure $ Left err
[ build ]
[ fatal ] Error when executing system command.
Command: "/home/jarlah/.pack/install/fa50df76de7892dc42f5588a36fb5657a4299242/idris2/bin/idris2" "--build" "http.ipkg"
Error code: 1

Full disclaimer: I really dont know what im doing here :) just pushing things around so other folks can see :)

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

Successfully merging this pull request may close these issues.

1 participant