-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Initial implementation of FTP #1122
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
Conversation
9772656
to
48668a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a WIP adding a blocking review to make sure it doesn't get merged at the current stage. Let me know when it's good to go and I can remove this review.
} | ||
} | ||
|
||
/* override func transferCompleted(withErrorCode errorCode: Int?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to remove the commented code.
@@ -128,12 +128,12 @@ internal final class _HTTPBodyFileSource { | |||
guard let channel = DispatchIO(type: .stream, path: fileSystemRepresentation, | |||
oflag: O_RDONLY, mode: 0, queue: workQueue, | |||
cleanupHandler: {_ in }) else { | |||
fatalError("Cant create DispatchIO channel") | |||
fatalError("Cant create DispatchIO channel") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation error.
if let location = response.allHeaderFields[value] as? String { | ||
return location | ||
} | ||
return nil | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two extra lines could be removed?
Foundation.xcodeproj/project.pbxproj
Outdated
@@ -1339,6 +1344,24 @@ | |||
path = Foundation; | |||
sourceTree = "<group>"; | |||
}; | |||
617F57F01F1F5C4B0004F3F0 /* libcurlhelpers */ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we should call the directory simply libcurl
(because it contains libcurl abstractions) instead of libcurlhelpers
internal let enableDebugOutput: Bool = { | ||
return (ProcessInfo.processInfo.environment["URLSessionDebug"] != nil) | ||
}() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may help if we could add a line or two describing the role of this new internal class :-)
return .completeTask | ||
} | ||
|
||
func seekInputStream(to position: UInt64) throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty method?
@@ -0,0 +1,700 @@ | |||
// Foundation/NSURLSession/TransferState.swift - NSURLSession & libcurl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this header refer to an apparently non-existent other file?
// Foundation | ||
// | ||
// Created by sai hema on 6/27/17. | ||
// Copyright © 2017 Apple. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be replaced with the standard header found in other Foundation files.
task?.response = response | ||
//We don't want a timeout to be triggered after this. The timeout timer needs to be cancelled. | ||
easyHandle.timeoutTimer = nil | ||
//because we deregister the task with the session on internalState being set to taskCompleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrap, capitalize, and space these comments to match the rest of the file.
705dc5b
to
39e96d8
Compare
39e96d8
to
9fa771e
Compare
9fa771e
to
868ea8e
Compare
ccc22de
to
e8fdce9
Compare
de89c00
to
da13e79
Compare
@swift-ci please test |
@pushkarnk Yes ..I have taken care of it .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a few basic review comments but had to stop as the PR is so large it is extremely difficult to review.
I would much prefer it if this was broken down into a series of incremental commits.
@@ -47,7 +47,7 @@ open class URLSessionConfiguration : NSObject, NSCopying { | |||
self.urlCredentialStorage = nil | |||
self.urlCache = nil | |||
self.shouldUseExtendedBackgroundIdleMode = false | |||
self.protocolClasses = [_HTTPURLProtocol.self] | |||
self.protocolClasses = [_HTTPURLProtocol.self,_FTPURLProtocol.self] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after comma.
@@ -0,0 +1,155 @@ | |||
// This source file is part of the Swift.org open source project | |||
// | |||
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/// return value's `isHeaderComplete` will then by `true`. | ||
/// | ||
/// - Throws: When a parsing error occurs | ||
func byAppendingFTP(headerLine data: Data, exectedContentLength: Int64) throws -> _NativeProtocol._TransferState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: expectedContentLength
@@ -40,15 +40,15 @@ internal func splitData(dispatchData data: DispatchData, atPosition position: In | |||
} | |||
|
|||
/// A (non-blocking) source for HTTP body data. | |||
internal protocol _HTTPBodySource: class { | |||
internal protocol _BodySource: class { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is no longer specific to HTTP, should it be moved out of the http directory?
} | ||
|
||
override func configureEasyHandle(for request: URLRequest) { | ||
//easyHandle.set(verboseModeOn: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these comments.
da13e79
to
1e0b318
Compare
1e0b318
to
43bcd81
Compare
@ianpartridge , I have addressed your comments. |
@ianpartridge : At this point incremental commits would be a laborious task, considering the refactoring effort involved .Do you have any other suggestions ? |
@alblue please review .. |
No I don't have any suggestions - personally I find this unreviewable 😢 |
We should have the URLSession refactoring part of this PR carved out into a different PR, because the objective of that refactor is to hoist some code (into a common super class) so that it can be reused in other native protocol implementations (we have the DATA protocol still unimplemented). |
@pushkarnk : I have raise another PR for the URLSession refactoring [https://github.com//pull/1216]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor observations
import Dispatch | ||
|
||
internal let enableLibcurlDebugOutput: Bool = { | ||
return (ProcessInfo.processInfo.environment["URLSessionDebugLibcurl"] != nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parenthesis around these values appear to have no value. Can you remove them, and get rid of the double-space after the return
keyword?
} | ||
|
||
func didReceive(data: Data) -> _EasyHandle._Action { | ||
guard case .transferInProgress(var ts) = internalState else { fatalError("Received body data, but no transfer in progress.") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you insert a newline after the {
and before the fatalError
, along with }
on its own line? That way the line size doesn't balloon for no reason.
} | ||
|
||
func validateHeaderComplete(transferSate: _TransferState) -> URLResponse? { | ||
guard transferSate.isHeaderComplete else { fatalError("Received body data, but the header is not complete, yet.") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
} | ||
|
||
fileprivate func notifyDelegate(aboutReceivedData data: Data) { | ||
guard let t = self.task else { fatalError("Cannot notify") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
} | ||
|
||
func fill(writeBuffer buffer: UnsafeMutableBufferPointer<Int8>) -> _EasyHandle._WriteBufferResult { | ||
guard case .transferInProgress(let ts) = internalState else { fatalError("Requested to fill write buffer, but transfer isn't in progress.") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
let dataTask1 = sesh.dataTask(with: req, completionHandler: { data, res, error in | ||
XCTAssertNil(error) | ||
defer { expect.fulfill() } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superflous blank line
let dataTask1 = sesh.downloadTask(with: req, completionHandler: { url, res, error in | ||
XCTAssertNil(error) | ||
defer { expect.fulfill() } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superflous blank line
let uploadTask = sesh.uploadTask(with: req, from: saveData, completionHandler: { data, res, error in | ||
XCTAssertNil(error) | ||
defer { expect.fulfill() } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superflous blank line
waitForExpectations(timeout: 20) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superflous blank lines
} | ||
|
||
extension SharedDelegate: URLSessionDownloadDelegate { | ||
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superflous blank lines
Sounds good - let's leave this as is for now, and after changes in #1216 come back and revisit this one? |
@ALBUE: Sure |
I'm of the opinion that leaving this PR open will result in confusion between this and the current version, which is in #1216. Seeing as we've still got a way to go before that one lands, and since the content in this pull request is out of date, I recommend we close this one, get #1216 addressed, and then you can rebase the changes on your |
Closing, and deferring future changes to subsequent PRs. |
This PR includes ..