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

NSData dataWithContentsOfURL hangs #2298

Closed
bviglietta opened this issue Mar 22, 2017 · 3 comments
Closed

NSData dataWithContentsOfURL hangs #2298

bviglietta opened this issue Mar 22, 2017 · 3 comments
Assignees
Milestone

Comments

@bviglietta
Copy link
Contributor

Trying to fetch the contents of a URL hangs. For instance, this call will never return, even though the HTTP request completes successfully:

NSURL* url = [NSURL URLWithString:@"https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png"];
NSData* data = [NSData dataWithContentsOfURL:url];
@ms-jihua
Copy link
Contributor

Tried a unit test with:

NSURL* url = [NSURL URLWithString:@"https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png"];
NSData* data = [NSData dataWithContentsOfURL:url];
ASSERT_OBJCNE(nil, data);

which completed successfully after a few seconds. Trying the associated sample app...

@rajsesh rajsesh assigned ms-jihua and unassigned rajsesh Mar 23, 2017
@rajsesh
Copy link
Contributor

rajsesh commented Mar 23, 2017

Unit tests don't quite have a main loop the same way a normal application does. it may be worth testing this in an app (FoundationDevTests app for example) or a functional test.

@rajsesh rajsesh added this to the 1704 milestone Mar 23, 2017
@rajsesh
Copy link
Contributor

rajsesh commented Mar 23, 2017

@ms-jihua just confirmed that this never really worked. Adding this to 1704 work.

@rajsesh rajsesh removed the Bug label Mar 23, 2017
ms-jihua added a commit to ms-jihua/WinObjC that referenced this issue Apr 7, 2017
    - Implement [NSURLConnection sendAsynchronousRequest:]
        - Re-implement [NSURLConnection sendSynchronousRequest:] on top of it, as stated in docs
    - Implement a not-yet fully-working setDelegateQueue: (callbacks are not yet called on it)
    - Remove NSURLConnectionState, replace with a lighter-weight, more flexible inner class
    - Changed the NSURLConnection functional tests to no longer run on the main run loop.
      This no longer works, which is correct (doesn't work on reference platform either)
        - Instead, run on another thread's run loop, and an operation queue.
        - Also added tests for sendSynchronousRequest:
    - Change parts of NSURLProtocol, NSRunLoop to use stricter typing
        - Change instances of NSRunLoopMode to actually say NSRunLoopMode instead of NSString*

Fixes microsoft#2298
ms-jihua added a commit that referenced this issue Apr 13, 2017
* Refactor parts of NSURLConnection
    - Implement [NSURLConnection sendAsynchronousRequest:]
        - Re-implement [NSURLConnection sendSynchronousRequest:] on top of it, as stated in docs
    - Implement a not-yet fully-working setDelegateQueue: (callbacks are not yet called on it)
    - Remove NSURLConnectionState, replace with a lighter-weight, more flexible inner class
    - Changed the NSURLConnection functional tests to no longer run on the main run loop.
      This no longer works, which is correct (doesn't work on reference platform either)
        - Instead, run on another thread's run loop, and an operation queue.
        - Also added tests for sendSynchronousRequest:
    - Change parts of NSURLProtocol, NSRunLoop to use stricter typing
        - Change instances of NSRunLoopMode to actually say NSRunLoopMode instead of NSString*

Fixes #2298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants