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

Add redirect follow feature #934

Merged
merged 4 commits into from
Oct 10, 2018
Merged

Add redirect follow feature #934

merged 4 commits into from
Oct 10, 2018

Conversation

kevinkassimo
Copy link
Contributor

@kevinkassimo kevinkassimo commented Oct 7, 2018

Closes #931

fetch_sync_string now follows redirect.

There was something called RedirectPolicy in an older version of hyper, but is currently dropped. I admit the code does not look very elegant, would try to simplify...

src/http.rs Outdated
.to_str()
.unwrap()
.to_string();
println!("Redirecting to {}...", &new_url_string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a debug!()

@@ -33,24 +31,46 @@ pub fn get_client() -> Client<Connector, hyper::Body> {
pub fn fetch_sync_string(module_name: &str) -> DenoResult<String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be very nice to have a unit test here... Not necessary but can you try uncommenting the test below? Maybe it has spontaneously been fixed...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that test would still get stuck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a bug similar to #919 here, adding a println! in the test unblocks the test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Ok. Good find - I will look into it tomorrow

Copy link
Contributor Author

@kevinkassimo kevinkassimo Oct 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ry Actually, tests somehow start to run again by removing the outer tokio_util::block_on. There is already another block_on inside of fetch_sync_string so it is not needed.

More mysteries to solve...
(At least we have runnable unit tests)

@qoh
Copy link
Contributor

qoh commented Oct 7, 2018

Apologies in advance if you intended to address it here and just didn't get to it yet or something like that:

Glad to see #931 addressed so quickly, but the description says that this also closes #930. It does fix the original problem that led me to find those two issues, but I don't see how it really fixes #930. deno shouldn't be resolving ./bar.ts from https://example/foo.ts as http:https://example/foo.ts, suddenly on a different protocol.

@kevinkassimo
Copy link
Contributor Author

kevinkassimo commented Oct 8, 2018

@qoh Right. Updated issue description.
Will try to address #930 later (I would be a bit busy in the coming days, would be glad if someone else comes with the PR before me)

@kevinkassimo
Copy link
Contributor Author

@ry Are we landing this, or waiting for a PR addressing #930 before this one?

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks Kevin - especially for adding the tests. Sorry for the delay.

s = SocketServer.TCPServer(("", REDIRECT_PORT), Handler)
print "Deno redirect server http:https://localhost:%d/ -> http:https://localhost:%d/" % (
REDIRECT_PORT, PORT)
return s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - well done

@ry
Copy link
Member

ry commented Oct 10, 2018

Can you rebase?

@kevinkassimo
Copy link
Contributor Author

@ry No hurries! Rebased.

@ry ry merged commit 888824c into denoland:master Oct 10, 2018
ry added a commit to ry/deno that referenced this pull request Oct 12, 2018
- Add --types command line flag.
- Add metrics()
- Add redirect follow feature denoland#934
- Fix clearTimer bug denoland#942
- Improve error printing denoland#935
- Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser,
  ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker
- Fix silent death on double await denoland#919
- Add Conn.closeRead() and Conn.closeWrite() denoland#903
@ry ry mentioned this pull request Oct 12, 2018
ry added a commit to ry/deno that referenced this pull request Oct 12, 2018
- Fix promise reject issue (denoland#936)
- Add --types command line flag.
- Add metrics()
- Add redirect follow feature denoland#934
- Fix clearTimer bug denoland#942
- Improve error printing denoland#935
- Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser,
  ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker
- Fix silent death on double await denoland#919
- Add Conn.closeRead() and Conn.closeWrite() denoland#903
ry added a commit that referenced this pull request Oct 12, 2018
- Fix promise reject issue (#936)
- Add --types command line flag.
- Add metrics()
- Add redirect follow feature #934
- Fix clearTimer bug #942
- Improve error printing #935
- Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser,
  ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker
- Fix silent death on double await #919
- Add Conn.closeRead() and Conn.closeWrite() #903
@kevinkassimo kevinkassimo deleted the feat/redirect branch December 27, 2019 07:52
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.

None yet

3 participants