예제 #1
0
int BuildRequestString(gfcrequest_t *gfr, char *serializedBuffer)
{
	printf("Building request\n");

	char *scheme = SchemeToString(gfr->Scheme);
	printf("Scheme: %s\n", scheme);

	char *method = MethodToString(gfr->Method);
	printf("Method: %s\n", method);

	char *path = gfr->Path;
	printf("Path: %s\n", path);

	char *terminator = "\r\n\r\n";

	int spaceSize = 1;
	int bufferLen = strlen(scheme) + spaceSize + strlen(method) + spaceSize + strlen(path) + spaceSize + strlen(terminator);
	printf("Buffer length: %d\n", bufferLen);

	serializedBuffer = realloc(serializedBuffer, (bufferLen + 1) * sizeof(char));
	memset(serializedBuffer, '\0', (bufferLen + 1) * sizeof(char));

	strcpy(serializedBuffer, scheme);
	strcat(serializedBuffer, " ");
	strcat(serializedBuffer, method);
	strcat(serializedBuffer, " ");
	strcat(serializedBuffer, path);
	strcat(serializedBuffer, " ");
	strcat(serializedBuffer, terminator);

	printf("Buffer contents: %s\n", serializedBuffer);
	return bufferLen;
}
예제 #2
0
void LetterChooser::Serialize(PersistentData& storageData)
{
	LetterManager::Serialize(storageData);
	storageData.SetName("LetterChooser");
	storageData.AddVector2Child(mDisplayMin,"DisplayMin");
	storageData.AddVector2Child(mDisplayMax,"DisplayMax");
	PersistentData* n = new PersistentData("LayoutScheme","LayoutScheme");
	storageData.AddChild(n);
	n->SetProperty("method",MethodToString());
	n->SetProperty("jitterStrength",mJitterStrength);
	n->SetProperty("rows",mRows);

}
예제 #3
0
const QString QHttpRequest::methodString() const
{
    return MethodToString(method());
}
예제 #4
0
RESPONSE_HEADER_RESULT 
ResponseHeaderBuilder::Build(
	String& OutResponse) const
{
	std::stringstream response; 
	
	response << ProtocolToString(Protocol) << " ";

	//
	// Some codes need special cases
	//
	if (Code == RESPONSE_MOVED ||
		Code == RESPONSE_FOUND)
	{
		if (!RedirectURI.size())
		{
			return RESPONSE_HEADER_NEED_REDIRECT_URI;
		}

		response 
			<< "URI: " 
			<< RedirectURI
			<< HTTP_LINE_ENDING;
	}
	else if (Code == RESPONSE_METHOD)
	{
		if (!RedirectURI.size())
		{
			return RESPONSE_HEADER_NEED_REDIRECT_URI;
		}

		response 
			<< "Method: " 
			<< MethodToString(Method) 
			<< " "
			<< RedirectURI 
			<< HTTP_LINE_ENDING;
	}
	else
	{
		response << Code << " " << ResponseCodeToString(Code) << HTTP_LINE_ENDING;
	}

	//
	// If we require authentication, say as much:
	//
	if (Code == RESPONSE_UNAUTHORISED)
	{
		if (AuthMode == AUTH_NONE)
		{
			return RESPONSE_HEADER_NEED_AUTH_MODE;
		}

		if (!AuthRealm.size())
		{
			return RESPONSE_HEADER_NEED_AUTH_REALM;
		}

		response 
			<< "WWW-Authenticate: " 
			<< AuthModeToString(AuthMode) 
			<< "Realm=\""
			<< AuthRealm 
			<< "\"" 
			<< HTTP_LINE_ENDING;
	}

	//
	// Add the keys
	//
	for (auto pair : m_ExtraLines)
	{
		response << pair.first << ":";
		if (pair.second.size())
			response << " " << pair.second;
		response << HTTP_LINE_ENDING;
	}

	// Terminating line break
	response << HTTP_LINE_ENDING;

	OutResponse = response.str();

	return RESPONSE_HEADER_OK;
}