- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 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
- 76
- 77
- 78
- 79
- 80
int AnalizingHeaderLine(char* HeadLine)
{
if(HeadLine==NULL) return -1;
if(strlen(HeadLine)==0) return 0;
if(!strncmp(HeadLine,"HTTP/",5))
ProcessStatusHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "date:",5))
ProcessDateHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "server:",7))
ProcessServerHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "last-modified:",14))
ProcessLastModHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "content-type:",13))
ProcessContTypeHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "content-length:",15))
ProcessContLenHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "pragma:",7))
ProcessPragmaHL(HeadLine);
else if(!strncmp(strlwr(HeadLine), "Connection",10))
ProcessConnectHL(HeadLine);
else printf("Unknown header line: %s\n", HeadLine);
return strlen(HeadLine);
}
int ProcessStatusHL(char* HeadLine)
{
short MinVer, MajVer;
char ResultStr[32];
char Num;
short Code;
Num = sscanf(HeadLine, "HTTP/%d.%d %d %s", &MinVer, &MajVer, &Code, ResultStr);
if(Num!=3 && Num!=4)
{ printf("Error status string\n");
return -1;
}
return Code;
}
int ProcessDateHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessServerHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessLastModHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessContTypeHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessContLenHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessPragmaHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
int ProcessConnectHL(char* HeadLine)
{
printf("%s\n",HeadLine);
return 0;
}
CGI. Обработка HTTP-заголовков. Rev. 1.0