Beispiel #1
0
void HTTPReadHeaders(STREAM *S, HTTPInfoStruct *Header)
{
char *Tempstr=NULL;


ListClear(Header->ServerHeaders,DestroyString);
Header->ContentLength=0;
Header->RedirectPath=CopyStr(Header->RedirectPath,"");
Header->Flags &= ~(HTTP_CHUNKED | HTTP_GZIP | HTTP_DEFLATE);
Tempstr=STREAMReadLine(Tempstr,S);
if (Tempstr)
{
HTTPParseResponseLine(S, Header,Tempstr);
Tempstr=STREAMReadLine(Tempstr,S);
}

while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
if (StrLen(Tempstr)==0) break;
HTTPParseHeader(S, Header,Tempstr);
Tempstr=STREAMReadLine(Tempstr,S);
}

S->BytesRead=0;
DestroyString(Tempstr);
}
Beispiel #2
0
void HTTPReadHeaders(STREAM *S, HTTPInfoStruct *Info)
{
char *Tempstr=NULL, *ptr;


ListClear(Info->ServerHeaders,DestroyString);
Info->ContentLength=0;

//Not needed
//Info->RedirectPath=CopyStr(Info->RedirectPath,"");
Info->Flags &= ~(HTTP_CHUNKED | HTTP_GZIP | HTTP_DEFLATE);
Tempstr=STREAMReadLine(Tempstr,S);
if (Tempstr)
{
	if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"RESPONSE: %s\n",Tempstr);
  if (strncmp(Tempstr,"HTTP/",5)==0)
  {
    ptr=strchr(Tempstr,' ');
    ptr++;

    Info->ResponseCode=CopyStrLen(Info->ResponseCode,ptr,3);
    STREAMSetValue(S,"HTTP:ResponseCode",Info->ResponseCode);
  
  }
Tempstr=STREAMReadLine(Tempstr,S);
}

while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
if (StrLen(Tempstr)==0) break;
HTTPParseHeader(S, Info,Tempstr);
Tempstr=STREAMReadLine(Tempstr,S);
}

//Handle Response Codes
if (StrLen(Info->ResponseCode))
{
		if (*Info->ResponseCode=='3') 
		{
			//No longer a flag, HTTP Redirect is now just a response code
			//Info->Flags |= HTTP_REDIRECT;
		}

		if (strcmp(Info->ResponseCode,"401")==0) 
		{
			if (Info->Authorization) Info->Authorization->Flags |= HTTP_AUTH_BASIC;
		}

		if (strcmp(Info->ResponseCode,"407")==0) 
		{
			if (Info->ProxyAuthorization) Info->ProxyAuthorization->Flags |= HTTP_PROXY_AUTH;
		}

}

S->BytesRead=0;
DestroyString(Tempstr);
}