Skip to content

Add 5 missing attributes to NSURLRequest #290

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

Closed
wants to merge 1 commit into from

Conversation

danieleggert
Copy link
Contributor

cachePolicy, timeoutInterval, networkServiceType, HTTPBody, and HTTPBodyStream
Rework how attributes are stored.
Refactor header field code into existingHeaderField().

@parkera
Copy link
Contributor

parkera commented Mar 16, 2016

@salgernon - please take a look

@parkera
Copy link
Contributor

parkera commented Mar 21, 2016

I think we intentionally left these out, but hopefully @salgernon can comment.

@danieleggert
Copy link
Contributor Author

I think it makes sense to have cachePolicy, timeoutInterval, and networkServiceType on all platforms.

@parkera
Copy link
Contributor

parkera commented Mar 21, 2016

If I recall correctly, the reason we left them out is that they are already properties on NSURLSession:

    /* default cache policy for requests */
    public var requestCachePolicy: NSURLRequestCachePolicy

    /* default timeout for requests.  This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. */
    public var timeoutIntervalForRequest: NSTimeInterval

    /* default timeout for requests.  This will cause a timeout if a resource is not able to be retrieved within a given timeout. */
    public var timeoutIntervalForResource: NSTimeInterval

    /* type of service for requests. */
    public var networkServiceType: NSURLRequestNetworkServiceType

    /* allow request to route over cellular. */
    public var allowsCellularAccess: Bool

@danieleggert
Copy link
Contributor Author

That's why NSURLSession has API that takes NSURL and API that takes NSURLRequest: The API that takes a request let's you override the values set by the NSURLSessionConfiguration. As the documentation states:

By creating a task based on a request object, you can tune various aspects of the task’s behavior, including the cache policy and timeout interval.

get { return super.networkServiceType }
set { super.networkServiceType = newValue }
}
public override var allowsCellularAccess: Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this ever be satisfied? It seems like it would require very specific hardware access

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'm fine with leaving allowsCellularAccess out.

@parkera
Copy link
Contributor

parkera commented Mar 22, 2016

Yes, it was at the request of the owner of this particular API that we do not have this override capability, because they were concerned about the complexity it introduces.

However, since we're not really getting any response on this right now, we may as well add this for parity since it's confusing people right now. Let's leave the cellular one out.

@danieleggert
Copy link
Contributor Author

I just noticed that HTTPBody and HTTPBodyStream are also missing. I’ll need these for #299 in order to implement POST and PUT requests. Thoughts?

cachePolicy, timeoutInterval, networkServiceType, HTTPBody, and HTTPBodyStream
Rework how attributes are stored.
Refactor header field code into existingHeaderField().
@parkera did not want allowsCellularAccess.
@danieleggert
Copy link
Contributor Author

I've removed allowsCellularAccess, but added HTTPBody and HTTPBodyStream.

@danieleggert danieleggert changed the title Add 4 missing attributes to NSURLRequest Add 5 missing attributes to NSURLRequest Mar 30, 2016
@danieleggert
Copy link
Contributor Author

Only after adding HTTPBody and HTTPBodyStream did I realise that these should not have been added because the NSURLSession API has separate methods for uploads (e.g. POST / PUT). Will remove these again. Sorry for the noise.

@phausler
Copy link
Contributor

phausler commented Apr 4, 2016

@swift-ci Please test

@danieleggert
Copy link
Contributor Author

I'll close this.

@danieleggert
Copy link
Contributor Author

C.f. #306

kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
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.

4 participants