             guard let boundryIndex = contentType.range(of: "boundary=") else {
                 return nil
             }
-            let boundry = contentType.substring(from: boundryIndex.upperBound).replacingOccurrences(of: "\"", with: "")
+            let boundary = contentType.substring(from: boundryIndex.upperBound).replacingOccurrences(of: "\"", with: "")
             return  {(bodyData: NSMutableData) -> ParsedBody? in
-                return parseMultipart(bodyData, boundary: boundry)
+                return parseMultipart(bodyData, boundary: boundary)
             }
         }
         return nil

                break
            case .body:
                // check if header
                if let labelRange = bodyLine.range(of: "content-type:", options: [.anchoredSearch, .caseInsensitiveSearch], range: Range<String.Index>(uncheckedBounds: (bodyLine.startIndex, bodyLine.endIndex))) {
                    currentPart.type = bodyLine.substring(from: bodyLine.index(after: labelRange.upperBound))
                    currentPart.headers[.type] = bodyLine
                } else if let labelRange = bodyLine.range(of: "content-disposition:", options: [.anchoredSearch, .caseInsensitiveSearch], range: Range<String.Index>(uncheckedBounds: (bodyLine.startIndex, bodyLine.endIndex))) {
                    if let nameRange = bodyLine.range(of: "name=", options: .caseInsensitiveSearch, range: Range<String.Index>(uncheckedBounds: (labelRange.upperBound, bodyLine.endIndex))) {
                        let valueStartIndex = bodyLine.index(after: nameRange.upperBound)
                        let valueEndIndex = bodyLine.range(of: "\"", range: Range<String.Index>(uncheckedBounds:(valueStartIndex, bodyLine.endIndex)))
                        currentPart.name = bodyLine.substring(with: Range<String.Index>(uncheckedBounds: (valueStartIndex, valueEndIndex?.lowerBound ?? bodyLine.endIndex)))
                    }
                    currentPart.headers[.disposition] = bodyLine
                } else if bodyLine.range(of: "content-transfer-encoding:", options: [.anchoredSearch, .caseInsensitiveSearch], range: Range<String.Index>(uncheckedBounds: (bodyLine.startIndex, bodyLine.endIndex))) != nil {
                    //TODO: Deal with this
                    currentPart.headers[.transferEncoding] = bodyLine
                } else {
                    // is data, add to data object
                    var dataLine = bodyLine
                    if data.length > 0 {
                        // data is multiline, add linebreaks back in
                        dataLine = "\r\n" + dataLine
                    }
                    if let lineData = dataLine.data(using: NSUTF8StringEncoding) {
                        data.append(lineData)
                    }
                }
            }
            
        }
        return nil
    }

    ///

    /// - Parameter bodyData: read data
    ///
    private class func parseMultipart(_ bodyData: NSMutableData, boundary: String) -> ParsedBody? {
        guard let boundaryData = String("--" + boundary).data(using: NSUTF8StringEncoding), let endBoundaryData = String("--" + boundary + "--").data(using: NSUTF8StringEncoding), let newLineData = "\r\n".data(using: NSUTF8StringEncoding) else {
            Log.error("Error converting strings to data for multipart parsing")
            return nil
        }
        
        enum ParseState {
            case preamble, body
        }
        var state = ParseState.preamble
        var parts: [Part] = []
        var currentPart = Part()
        var partData = NSMutableData()
        let bodyLines = divideDataByNewLines(data: bodyData, newLineData: newLineData)
        // main parse loop
        for bodyLine in bodyLines {
            switch(state) {
            case .preamble where bodyLine.hasPrefix(boundaryData), .body where bodyLine.hasPrefix(boundaryData):
                // boundary found
                if partData.length > 0 {
                    if let parser = getParsingFunction(contentType: currentPart.type), let parsedBody = parser(partData) {
                        currentPart.body = parsedBody
                    } else {
                        currentPart.body = .raw(partData)
                    }
                    parts.append(currentPart)
                }
                currentPart = Part()
                partData = NSMutableData()
                if bodyLine.hasPrefix(endBoundaryData) {
                    // end boundary found, end of parsing
                    return .multipart(parts)
                }
