Fossil ISAPI

Check-in [8559f2a709]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed anything except cookie! Now all headers are sent correctly.
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:8559f2a709bb48cfa5b59377aae41f45b7160cd0
User & Date: Kamyar 2012-12-31 00:09:31
Context
2012-12-31
00:09
Fixed anything except cookie! Now all headers are sent correctly. Leaf check-in: 8559f2a709 user: Kamyar tags: trunk
2012-12-23
16:50
Fixed some bugs. Cookies still buggy! check-in: 89e4f22c5f user: K.Inanloo tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to FossilIsapi/FossilIsapi.cpp.

19
20
21
22
23
24
25

26

27
28
29
30
31
32
33
34
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63



64
65






66
67





68
69
70


71
72
73



74
75
}


/*  This function is called when the extension is accessed */
DWORD WINAPI
	HttpExtensionProc( LPEXTENSION_CONTROL_BLOCK ecb )
{

	char *header   = new char[255];

	DWORD headerlen;	

	/* Use a server support function to write out a header with our
	additional header information */


	std::string output;
	const int MAX_BUFFER = 4096;
................................................................................
		char* value = new char[255];
		ecb->GetServerVariable(ecb->ConnID, lpString[i], value, &size);		
		_putenv_s(lpString[i], value);
	}

	char* fossil = new char[255];
	sprintf_s(fossil, 255, "fossil %s", std::getenv("FOSSIL_CONFIG"));
	FILE *stream = _popen(fossil, "r");	

	ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID) TRUE,
		NULL, NULL);

	while(fscanf_s(stream, "%[^\n]", header, 255)) {
		headerlen  = strlen( header );
		ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, 0,

			&headerlen, (DWORD *)header );



	}
	







	SIZE_T len;





	while ((len = fread(buffer, 1, MAX_BUFFER, stream)) != NULL )
		ecb->WriteClient( ecb->ConnID, buffer, &len, 0 );	
	free(buffer);


	_pclose(stream);	
	
	/* Return, indicating success */



	return HSE_STATUS_SUCCESS;
}







>
|
>
|







 







|




|
|
<
>
|
>
>
>


>
>
>
>
>
>
|

>
>
>
>
>
|
|
<
>
>


<
>
>
>


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89

90
91
92
93
94
}


/*  This function is called when the extension is accessed */
DWORD WINAPI
	HttpExtensionProc( LPEXTENSION_CONTROL_BLOCK ecb )
{
	char *headerItem = new char[255];
	char *status = new char[255];
	std::string header;
	DWORD headerItemLen;

	/* Use a server support function to write out a header with our
	additional header information */


	std::string output;
	const int MAX_BUFFER = 4096;
................................................................................
		char* value = new char[255];
		ecb->GetServerVariable(ecb->ConnID, lpString[i], value, &size);		
		_putenv_s(lpString[i], value);
	}

	char* fossil = new char[255];
	sprintf_s(fossil, 255, "fossil %s", std::getenv("FOSSIL_CONFIG"));
	FILE *stream = _popen(fossil, "rb");	

	ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID) TRUE,
		NULL, NULL);

	fgets(status, 255, stream);
	status[strlen(status)-1] = '\0';	


	while(fgets(headerItem, 255, stream) != NULL && (headerItemLen = strlen(headerItem)) > 2) {		
		headerItem[headerItemLen-1] = '\r';
		header.append(headerItem).append("\n");
		memset(headerItem, 0, 255);		
	}
	
	HSE_SEND_HEADER_EX_INFO headerInfo;
	headerInfo.pszStatus = status + 8;
	headerInfo.cchStatus = strlen(status) - 8;
	headerInfo.pszHeader = header.c_str();
	headerInfo.cchHeader = header.length();
	ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX,  &headerInfo, NULL, NULL);
	
	SIZE_T len;

	char* crlf = "\r\n";
	len = 2;
	ecb->WriteClient(ecb->ConnID, crlf, &len, 0);

	while ((len = fread(buffer, 1, MAX_BUFFER, stream)) != NULL ){		
		ecb->WriteClient( ecb->ConnID, buffer, &len, 0 );

	}
	
	_pclose(stream);	
	

	if(ferror(stream) != NULL)
		return HSE_STATUS_ERROR;

	return HSE_STATUS_SUCCESS;
}