NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

iOS: Does not follow recursive redirect #104

Open Tronix117 opened 6 years ago

Tronix117 commented 6 years ago

When final response is a Redirection, it should follow the redirect, and then make the completion. Right now, it just hangs and complete/responded events are never notified.

Edit: it actualy occurs when redirection response is also a redirection. It should recursively follow redirection until a certain configurable limit (followRedirect: number = 10)

lini commented 6 years ago

I tried to reproduce this issue in iOS and the demo app from this repository but everything worked as expected.

I modified the server at /examples/www/server.js and added the following code:

response.writeHead(301, {
  Location: "http://some_test_url/"
});
response.end();

to redirect to a simple page with the text "DONE WITH REDIRECT!". After the file upload, the redirect worked:

image

If you still experience this issue, please check your server code to see how the redirect is performed.

Tronix117 commented 6 years ago

Note: I'm using multipart

I will double checked. Right now in emergency I had to write a Proxy sending directly the response. Actualy, the complete scenario is to post a video to a video provider (vimeo), except the only moment they send us the final video_id is at the end of the upload (weird implementation):

  1. At the end of the upload : 301 to their server somewhere
  2. This redirect emit a second redirect : 301 to the redirect uri provided with a video_id parameter appended.

Maybe it follows the first redirect, but fails to follow the second one ? Anyway, the upload just hangs, we only have currentBytes === totalBytes on last progress, but neither complete, responded nor error is emitted.

The only thing I need is to retrieve this video_id for which I need to know the Location header of the second redirect, or at least the URL of the last redirect. But even when it works, we don't have a full access to the response except for the data.

That's not ideal, but I think I will rely on my proxy right now (for the cost of extra bandwidth) which send me back a sanitized JSON response.