Skip to content

fix(http): should throw an exception if input to http.request is not string or Request #4245

Closed

Description

@jeffbcross

I forgot to import Request in an example where I instantiate Request manually, which meant I was instantiating the global Request object instead of Request provided by angular2/http. When passing this to Http.prototype.request, the input didn't match the string or instanceof Request check, so the method was returning `undefined. Instead, an exception should be raised.

Activity

  1. jeffbcross commented on Sep 18, 2015

    @jeffbcross
    ContributorAuthor

    Here's where the change should occur:

    } else if (url instanceof Request) {

  2. bkyarger commented on Sep 18, 2015

    @bkyarger
    Contributor

    I'd like to tackle this one.

  3. jeffbcross commented on Sep 18, 2015

    @jeffbcross
    ContributorAuthor

    It's all you, @bkyarger! LMK if you need help writing/running unit tests.

  4. self-assigned this
    on Sep 18, 2015
  5. bkyarger commented on Sep 18, 2015

    @bkyarger
    Contributor

    @jeffbcross can you show me an example of how you instantiate the global Request object manually? I'm not sure how to do that in Typescript for my test.

  6. jeffbcross commented on Sep 18, 2015

    @jeffbcross
    ContributorAuthor

    @bkyarger what we could do instead of instantiating a global Request (which isn't present in all test environments) is just provide a value to the request function that isn't really a Request or string, but tell typescript that it is.

    var req = <Request>{};
    expect(() => http.request(req)).toThrow('some error');
  7. bkyarger commented on Sep 18, 2015

    @bkyarger
    Contributor

    Awesome, I'll do that. Thanks!

  8. bkyarger commented on Sep 18, 2015

    @bkyarger
    Contributor

    @jeffbcross I've got the change implemented with a test, but I'm having trouble getting the entire npm test suite to complete. When it launches firefox to perf tests FF is crashing (I think when installing the xpi) so the perf tests eventually time out. I'm on OSX and my FF is up to date. Any suggestions or workarounds?

  9. jeffbcross commented on Sep 18, 2015

    @jeffbcross
    ContributorAuthor

    @bkyarger If unit tests are passing, and if gulp check-format passes, I would just go ahead and open a PR and let Travis run the tests. If gulp check-format fails, it provides a script you can run to automatically clean up formatting.

  10. bkyarger commented on Sep 18, 2015

    @bkyarger
    Contributor

    Yep, both of those are passing. PR on the way. Thanks!

  11. added a commit that references this issue on Sep 25, 2015
    e9def91
  12. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  13. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions