Code: Select all
Receive←{
⎕IO←0 ⋄ ⎕ML←3
⍺←''
r←DRC.Wait ⍵ 20000
0≠↑r:(↑r)(1⊃r)''
'BlockLast'≡2⊃r:0 ''(⍺,3⊃r)
'Error'≡2⊃r:1(3⊃r)''
(⍺,3⊃r)∇ ⍵
}
The right arg is simply the connection name. The result is three items: a return code, an error message, and then the received data, inlcuding the header.
In the HTTPGet function, there is additional checking to see if the content length has been reached, which requires partially processing the header as you loop around the Wait function.
My questions are:
1) Is one guaranteed to get a "BlockLast" event?
2) If you wait to terminate until the BlockLast, will your data received perhaps be longer than the specified content lenght in the header?
3) Are you guaranteed to get at least the entire header in the first call to Wait?
The above function appears to work, but I'm sure it's a bit simplistic. Any comments or pointers would be appreciated.