Ejemplo n.º 1
0
bool MPFD::Parser::ProcessContentOfTheField() {
    long BoundaryPosition = BoundaryPositionInDataCollector();
    long DataLengthToSendToField;
    if (BoundaryPosition >= 0) {
        // 2 is the \r\n before boundary we do not need them
        DataLengthToSendToField = BoundaryPosition - 2;
    } else {
        // We need to save +2 chars for \r\n chars before boundary
		if(DataCollectorLength < (long)(Boundary.length() + 2))
        	DataLengthToSendToField = DataCollectorLength - 2;							// bug fixed by gunoodaddy
		else
        	DataLengthToSendToField = DataCollectorLength - (Boundary.length() + 2);	// this author's thinking...
    }

    if (DataLengthToSendToField > 0) {
        CurrentField->AcceptSomeData(DataCollector, DataLengthToSendToField);
		Fields.push_back(CurrentField);
		CurrentField = NULL;
        TruncateDataCollectorFromTheBeginning(DataLengthToSendToField);
    }

    if (BoundaryPosition >= 0) {
        CurrentStatus = Status_LookingForStartingBoundary;
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 2
0
bool MPFD::Parser::FindStartingBoundaryAndTruncData() {
    long n = BoundaryPositionInDataCollector();
    if (n >= 0) {
        TruncateDataCollectorFromTheBeginning(n + Boundary.length());
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 3
0
bool MPFD::Parser::WaitForHeadersEndAndParseThem() {
    for (int i = 0; i < DataCollectorLength - 3; i++) {
        if ((DataCollector[i] == 13) && (DataCollector[i + 1] == 10) && (DataCollector[i + 2] == 13) && (DataCollector[i + 3] == 10)) {
            long headers_length = i;
            char *headers = new char[headers_length + 1];
            memset(headers, 0, headers_length + 1);
            memcpy(headers, DataCollector, headers_length);

            _ParseHeaders(std::string(headers));

            TruncateDataCollectorFromTheBeginning(i + 4);

            delete headers;

            return true;
        }
    }
    return false;
}
Ejemplo n.º 4
0
bool MPFD::Parser::ProcessContentOfTheField() {
    long BoundaryPosition = BoundaryPositionInDataCollector();
    long DataLengthToSendToField;
    if (BoundaryPosition >= 0) {
        // 2 is the \r\n before boundary we do not need them
        DataLengthToSendToField = BoundaryPosition - 2;
    } else {
        // We need to save +2 chars for \r\n chars before boundary
        DataLengthToSendToField = DataCollectorLength - (Boundary.length() + 2);
    }

    if (DataLengthToSendToField > 0) {
        Fields[ProcessingFieldName]->AcceptSomeData(DataCollector, DataLengthToSendToField);
        TruncateDataCollectorFromTheBeginning(DataLengthToSendToField);
    }

    if (BoundaryPosition >= 0) {
        CurrentStatus = Status_LookingForStartingBoundary;
        return true;
    } else {
        return false;
    }
}