Exemple #1
0
char *HTTP_Request(URL *Url,Header *request_head,Body *request_body)
{
 char *msg=NULL,*head;

 /* Make the request OK for a proxy or not. */

 if(proxyUrl)
    MakeRequestProxyAuthorised(proxyUrl,request_head);
 else
    MakeRequestNonProxy(Url,request_head);

 /* Send the request. */

 head=HeaderString(request_head);

 if(proxyUrl)
    PrintMessage(ExtraDebug,"Outgoing Request Head (to proxy)\n%s",head);
 else
    PrintMessage(ExtraDebug,"Outgoing Request Head (to server)\n%s",head);

 if(write_string(server,head)==-1)
    msg=GetPrintMessage(Warning,"Failed to write head to remote HTTP %s; [%!s].",proxyUrl?"proxy":"server");
 if(request_body)
    if(write_data(server,request_body->content,request_body->length)==-1)
       msg=GetPrintMessage(Warning,"Failed to write body to remote HTTP %s; [%!s].",proxyUrl?"proxy":"server");

 free(head);

 return(msg);
}
Exemple #2
0
char *HTTP_Request(Connection *connection,URL *Url,Header *request_head,Body *request_body)
{
 char *msg=NULL,*head; size_t headlen;
 URL *proxyUrl=connection->proxyUrl;

 /* Make the request OK for a proxy or not. */

 if(proxyUrl)
    MakeRequestProxyAuthorised(proxyUrl,request_head);
 else
    MakeRequestNonProxy(Url,request_head);

 /* Send the request. */

 head=HeaderString(request_head,&headlen);

 if(proxyUrl)
    PrintMessage(ExtraDebug,"Outgoing Request Head (to proxy)\n%s",head);
 else
    PrintMessage(ExtraDebug,"Outgoing Request Head (to server)\n%s",head);

 if(write_data(connection->fd,head,headlen)<0)
    msg=GetPrintMessage(Warning,"Failed to write head to remote HTTP %s; [%!s].",proxyUrl?"proxy":"server");
 else if(request_body && write_data(connection->fd,request_body->content,request_body->length)<0)
    msg=GetPrintMessage(Warning,"Failed to write body to remote HTTP %s; [%!s].",proxyUrl?"proxy":"server");

 free(head);

 return(msg);
}