/* Copyright 2001 2002 Debajyoti Bera */
/* This file is part of mGet.
* mGet is free Software; please refer to COPYING for terms and conditions */
#include "http_connect.h"
int do_http_CONNECT(SOCKET s){
int ret;
char version[10]={0}, buffer[LENGTH], *request_string;
int status_code;
//make the request string to send http CONNECT
request_string=(char *)calloc(sizeof(char), strlen(CONNECT_STR) + strlen(host_name) + 5 /*port*/ + strlen(user_passwd));
sprintf(request_string, CONNECT_STR, host_name, port, user_passwd);
DEBUGPRINT(fprintf(outfile, "CONNECT request sent =>\n%s\n", request_string))
ret=send(s, request_string, strlen(request_string), 0);
memset(buffer, '\0', LENGTH);
ret=recv(s, buffer, LENGTH-1, 0);
if(ret<0)
err_exit("Receive error", 1, s);
buffer[ret]='\0';
strncpy(error_buffer, buffer, 1023);
DEBUGPRINT(fprintf(outfile, "CONNECT response:%s\n", buffer))
_process_status_line(buffer, version, &status_code);
DEBUGPRINT(fprintf(outfile,"HTTP CONNECT: version=%s status code=%d\n", version, status_code))
return status_code;
};
syntax highlighted by Code2HTML, v. 0.9.1