File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,12 @@ IO.puts("Status: #{response.status}")
3434text = HTTP .Response .text (response)
3535{:ok , json} = HTTP .Response .json (response)
3636
37- # Read response as stream (raw binary)
38- {:ok , response} =
39- HTTP .fetch (" https://jsonplaceholder.typicode.com/posts/1" , [
40- options: [body_format: :binary ]
41- ])
37+ # Read response body as raw binary
38+ response =
39+ HTTP .fetch (" https://jsonplaceholder.typicode.com/posts/1" )
4240 |> HTTP .Promise .await ()
4341
44- # response.body is now a binary stream you can process chunk by chunk
42+ # response.body contains the raw binary data
4543binary_data = response.body
4644
4745# POST request with JSON
@@ -116,14 +114,12 @@ Represents an HTTP response.
116114text = HTTP .Response .text (response)
117115{:ok , json} = HTTP .Response .json (response)
118116
119- # Read response as stream (raw binary)
120- {:ok , response} =
121- HTTP .fetch (" https://api.example.com/large-file" , [
122- options: [body_format: :binary ]
123- ])
117+ # Access raw response body as binary
118+ response =
119+ HTTP .fetch (" https://api.example.com/large-file" )
124120 |> HTTP .Promise .await ()
125121
126- # Process binary response in chunks
122+ # response.body contains the raw binary response data
127123binary_data = response.body
128124```
129125
You can’t perform that action at this time.
0 commit comments