-
Notifications
You must be signed in to change notification settings - Fork 19
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
Client upload progress #57
Comments
or to make sure the response won't get lost, request could return: {
progress: Signal<Float>,
repsonse: Future<IncomingResponse>,
} |
Hm... should even split to uploadProgress and downloadProgress |
and need a way to abort |
Progress is tricky, because in either direction content-length needn't be set. I guess this is roughly the best we can do: interface HttpTransaction {
var bytesWritten(get, never):Observable<Int>;
var bytesRead(get, never):Observable<Int>;
var response(get, never):Future<IncomingResponse>;
function abort():Future<Bool>;
} Aborting is going to be a PITA, I can tell you. A lot of fun stuff like ensuring the body of the |
Can we still include content length and make it |
Now we have |
I think it is just: function request(req:OutgoingRequest):Progress<Outcome<IncomingResponse, Error>>; |
Hmm. Looking at the signature, I would probably expect to the progress to report on the download, rather than the upload. I'm still inclined to think that we might want to return a more complex object that has an upload and download progress and the response. Or it could be something like: function request(req:OutgoingRequest, ?handlers:{ ?upload:ProgressValue->Void, ?download:ProgressValue->Void }):Progress<Outcome<IncomingResponse, Error>>; Still doesn't really handle the topic of cancelation though. |
I wrongly thought that the response is only available after the upload is finished but it should not be the case. I think HTTP can produce a response header as soon as the request header is received, without the completely receiving the request body. So As for download progress I thought it should be deduced from the reading of the response body tink_http/src/tink/http/Fetch.hx Lines 133 to 176 in f7ccf01
|
Suggest changing the api to:
function request(request:OutgoingRequest): Signal<Progress<IncomingResponse>>
and
enum Progress<T> { Done(data:<T>); Progress(fraction:Float); Failed(error:Error);}
The text was updated successfully, but these errors were encountered: