Beispiel #1
0
STREAM *HTTPMethod(char *Method, char *URL, char *Logon, char *Password, char *ContentType, char *ContentData, int ContentLength)
{
HTTPInfoStruct *Info;
STREAM *S;


Info=HTTPInfoFromURL(Method, URL);

if (StrLen(ContentType))
{
Info->PostContentType=CopyStr(Info->PostContentType,ContentType);
Info->PostData=CopyStr(Info->PostData,ContentData);
Info->PostContentLength=ContentLength;
}

if (StrLen(Logon) || StrLen(Password))
{
	if (! Info->Authorization) Info->Authorization=(HTTPAuthStruct *) calloc(1,sizeof(HTTPAuthStruct));

	if (Logon==HTTP_AUTH_BY_TOKEN) HTTPAuthSet(Info->Authorization,"", Password, HTTP_AUTH_TOKEN);
	else HTTPAuthSet(Info->Authorization,Logon, Password, HTTP_AUTH_BASIC);
}
S=HTTPTransact(Info);

HTTPInfoDestroy(Info);
return(S);
}
Beispiel #2
0
HTTPInfoStruct *HTTPInfoFromURL(char *Method, char *URL)
{
HTTPInfoStruct *Info;
char *Proto=NULL, *User=NULL, *Pass=NULL, *Token=NULL;
char *ptr=NULL;
int Port=0;


Info=HTTPInfoCreate("", 0, "", "", Method, "", "",0);
if (strcasecmp(Method,"POST")==0) ParseURL(URL, &Proto, &Info->Host, &Token, &User, &Pass,&Info->Doc,&Info->PostData);
else ParseURL(URL, &Proto, &Info->Host, &Token, &User, &Pass,&Info->Doc, NULL);
Info->Port=atoi(Token);

if (StrLen(User) || StrLen(Pass))
{
	Info->Authorization=(HTTPAuthStruct *) calloc(1,sizeof(HTTPAuthStruct));
	HTTPAuthSet(Info->Authorization,User, Pass, HTTP_AUTH_BASIC);
}

if (strcmp(Proto,"https")==0) Info->Flags |= HTTP_SSL;

if (StrLen(Info->PostData))
{
	Info->PostContentType=CopyStr(Info->PostContentType,"application/x-www-form-urlencoded");
	Info->PostContentLength=StrLen(Info->PostData);
}

DestroyString(User);
DestroyString(Pass);
DestroyString(Token);
DestroyString(Proto);

return(Info);
}
Beispiel #3
0
STREAM *HTTPMethod(char *Method, char *URL, char *Logon, char *Password)
{
HTTPInfoStruct *Info;
STREAM *S;


Info=HTTPInfoFromURL(Method, URL);
if (StrLen(Logon) || StrLen(Password))
{
	if (! Info->Authorization) Info->Authorization=(HTTPAuthStruct *) calloc(1,sizeof(HTTPAuthStruct));
	HTTPAuthSet(Info->Authorization,Logon, Password, HTTP_AUTH_BASIC);
}
S=HTTPTransact(Info);

HTTPInfoDestroy(Info);
return(S);
}
Beispiel #4
0
STREAM *HTTPPost(char *URL, char *Logon, char *Password, char *ContentType, char *Content)
{
HTTPInfoStruct *Info;
STREAM *S;


Info=HTTPInfoFromURL("POST", URL);
Info->PostContentType=CopyStr(Info->PostContentType,ContentType);
Info->PostData=CopyStr(Info->PostData,Content);
Info->PostContentLength=StrLen(Content);
if (StrLen(Logon) || StrLen(Password))
{
  if (! Info->Authorization) Info->Authorization=(HTTPAuthStruct *) calloc(1,sizeof(HTTPAuthStruct));
  HTTPAuthSet(Info->Authorization,Logon, Password, HTTP_AUTH_BASIC);
}
S=HTTPTransact(Info);

HTTPInfoDestroy(Info);
return(S);
}
Beispiel #5
0
void HTTPInfoSetAuth(HTTPInfoStruct *Info, char *Logon, char *Password, int Type)
{
if (! Info->Authorization) Info->Authorization=(HTTPAuthStruct *) calloc(1,sizeof(HTTPAuthStruct));
HTTPAuthSet(Info->Authorization,Logon, Password, Type);
}