Skip to content

Commit

Permalink
Merge pull request #2 from vapor/alpha
Browse files Browse the repository at this point in the history
alpha
  • Loading branch information
loganwright authored Feb 16, 2017
2 parents 2ea24e5 + 01aa31d commit 8f413a0
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import PackageDescription
let package = Package(
name: "Multipart",
targets: [
// RFC 2046
// RFC 2046
Target(name: "Multipart"),

// RFC 2388
Target(name: "FormData", dependencies: ["Multipart"])
],
dependencies: [
// Core extensions, type-aliases, and functions that facilitate common tasks
.Package(url: "https://github.com/vapor/core.git", majorVersion: 1),
.Package(url: "https://github.com/vapor/core.git", Version(2,0,0, prereleaseIdentifiers: ["alpha"])),

// HTTP package for HeaderKey type
.Package(url: "https://github.com/vapor/engine.git", majorVersion: 1)
.Package(url: "https://github.com/vapor/engine.git", Version(2,0,0, prereleaseIdentifiers: ["alpha"]))
]
)
6 changes: 3 additions & 3 deletions Sources/FormData/ContentDispositionParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class ContentDispositionParser {
case .none:
state = .parsingPrefix(buffer: [byte])
case .parsingPrefix(var buffer):
if byte == .semicolon && buffer == "form-data".bytes {
if byte == .semicolon && buffer == "form-data".makeBytes() {
state = .parsingKey(buffer: [])
break main
}
Expand All @@ -57,9 +57,9 @@ final class ContentDispositionParser {

if byte == .equals {
switch buffer {
case "name".bytes:
case "name".makeBytes():
state = .parsingValue(key: .name, buffer: [])
case "filename".bytes:
case "filename".makeBytes():
state = .parsingValue(key: .filename, buffer: [])
default:
state = .parsingValue(key: .other(buffer), buffer: [])
Expand Down
2 changes: 1 addition & 1 deletion Sources/FormData/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class Parser {
var name: String?
var filename: String?

for byte in contentDisposition.bytes {
for byte in contentDisposition.makeBytes() {
parser.parse(byte)

switch parser.state {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FormData/Serializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public final class Serializer {
/// Generates a Content-Type header value from a boundary
public static func generateContentType(boundary: BytesConvertible) throws -> Bytes {
let b = try boundary.makeBytes()
return "multipart/form-data; boundary=".bytes + b
return "multipart/form-data; boundary=".makeBytes() + b
}
}
2 changes: 1 addition & 1 deletion Sources/Multipart/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final class Parser {
guard boundaryPieces.count == 2 else {
throw Error.invalidBoundary
}
return boundaryPieces[1].bytes
return boundaryPieces[1].makeBytes()
}

/// Create a new multipart parser from a
Expand Down
4 changes: 2 additions & 2 deletions Sources/Multipart/Serializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public final class Serializer {
serialize(boundary)
serialize(crlf)
for (key, value) in part.headers {
serialize(key.key.bytes)
serialize(key.key.makeBytes())
serialize(.colon)
serialize(.space)
serialize(value.bytes)
serialize(value.makeBytes())
serialize(crlf)
}
serialize(crlf)
Expand Down
4 changes: 2 additions & 2 deletions Tests/FormDataTests/SerializerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class SerializerTests: XCTestCase {
public func testBasic() throws {
let part1 = Part(headers: [
"Content-Type": "text/plain; charset=us-ascii",
], body: "Systems should choose the 'best' type based on the local environment and references, in some cases even through user interaction.".bytes)
], body: "Systems should choose the 'best' type based on the local environment and references, in some cases even through user interaction.".makeBytes())

let part2 = Multipart.Part(headers: [:], body: "Test123".bytes)
let part2 = Multipart.Part(headers: [:], body: "Test123".makeBytes())

let field1 = Field(name: "title", filename: nil, part: part1)
let field2 = Field(name: "image", filename: "image.jpg", part: part2)
Expand Down
12 changes: 6 additions & 6 deletions Tests/MultipartTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ParserTests: XCTestCase {

func testInit() throws {
let parser = try Parser(boundary: "foo")
XCTAssertEqual(parser.boundary, "foo".bytes)
XCTAssertEqual(parser.boundary, "foo".makeBytes())
}

func testPreamble() throws {
Expand All @@ -38,7 +38,7 @@ class ParserTests: XCTestCase {
preambleExpectation.fulfill()
}

try parser.parse(message.bytes)
try parser.parse(message.makeBytes())

waitForExpectations(timeout: 0, handler: nil)
}
Expand All @@ -63,7 +63,7 @@ class ParserTests: XCTestCase {
preambleExpectation.fulfill()
}

try parser.parse(message.bytes)
try parser.parse(message.makeBytes())

waitForExpectations(timeout: 0, handler: nil)
}
Expand Down Expand Up @@ -93,7 +93,7 @@ class ParserTests: XCTestCase {
partExpectation.fulfill()
}

try parser.parse(message.bytes)
try parser.parse(message.makeBytes())

waitForExpectations(timeout: 0, handler: nil)
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class ParserTests: XCTestCase {
partExpectation.fulfill()
}

try parser.parse(message.bytes)
try parser.parse(message.makeBytes())

waitForExpectations(timeout: 0, handler: nil)
}
Expand All @@ -147,7 +147,7 @@ class ParserTests: XCTestCase {
epilogueExpectation.fulfill()
}

try parser.parse(message.bytes)
try parser.parse(message.makeBytes())

// must call done since epilogue can go on forever
try parser.finish()
Expand Down
6 changes: 3 additions & 3 deletions Tests/MultipartTests/SerializerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class SerializerTests: XCTestCase {

func testInit() throws {
let serializer = try Serializer(boundary: "foo")
XCTAssertEqual(serializer.boundary, "foo".bytes)
XCTAssertEqual(serializer.boundary, "foo".makeBytes())
}

public func testBasic() throws {
let part1 = Part(headers: [
"Content-Type": "text/plain; charset=us-ascii",
"X-Test": "42"
], body: "Systems should choose the 'best' type based on the local environment and references, in some cases even through user interaction.".bytes)
], body: "Systems should choose the 'best' type based on the local environment and references, in some cases even through user interaction.".makeBytes())

let part2 = Part(headers: [:], body: "Test123".bytes)
let part2 = Part(headers: [:], body: "Test123".makeBytes())

let serializer = try Serializer(boundary: "boundary42")

Expand Down

0 comments on commit 8f413a0

Please sign in to comment.