void Curl_easy_initHandleData(struct SessionHandle *data)
{
- memset(&data->req, 0, sizeof(struct SingleRequest));
- data->req.maxdownload = -1;
+ (void)data;
}
/*
data->state.path = NULL;
- Curl_safefree(data->state.proto.generic);
+ Curl_free_request_state(data);
/* zero out UserDefined data: */
Curl_freeset(data);
static CURLcode file_connect(struct connectdata *conn, bool *done);
static CURLcode file_disconnect(struct connectdata *conn,
bool dead_connection);
-
+static CURLcode file_setup_connection(struct connectdata *conn);
/*
* FILE scheme handler.
const struct Curl_handler Curl_handler_file = {
"FILE", /* scheme */
- ZERO_NULL, /* setup_connection */
+ file_setup_connection, /* setup_connection */
file_do, /* do_it */
file_done, /* done */
ZERO_NULL, /* do_more */
};
+static CURLcode file_setup_connection(struct connectdata *conn)
+{
+ /* allocate the FILE specific struct */
+ conn->data->req.protop = calloc(1, sizeof(struct FILEPROTO));
+ if(!conn->data->req.protop)
+ return CURLE_OUT_OF_MEMORY;
+
+ return CURLE_OK;
+}
+
/*
Check if this is a range download, and if so, set the internal variables
properly. This code is copied from the FTP implementation and might as
{
struct SessionHandle *data = conn->data;
char *real_path;
- struct FILEPROTO *file;
+ struct FILEPROTO *file = data->req.protop;
int fd;
#ifdef DOS_FILESYSTEM
int i;
if(!real_path)
return CURLE_OUT_OF_MEMORY;
- file = calloc(1, sizeof(struct FILEPROTO));
- if(!file) {
- free(real_path);
- return CURLE_OUT_OF_MEMORY;
- }
- data->state.proto.file = file;
-
#ifdef DOS_FILESYSTEM
/* If the first character is a slash, and there's
something that looks like a drive at the beginning of
static CURLcode file_done(struct connectdata *conn,
CURLcode status, bool premature)
{
- struct FILEPROTO *file = conn->data->state.proto.file;
+ struct FILEPROTO *file = conn->data->req.protop;
(void)status; /* not used */
(void)premature; /* not used */
static CURLcode file_disconnect(struct connectdata *conn,
bool dead_connection)
{
- struct FILEPROTO *file = conn->data->state.proto.file;
+ struct FILEPROTO *file = conn->data->req.protop;
(void)dead_connection; /* not used */
if(file) {
static CURLcode file_upload(struct connectdata *conn)
{
- struct FILEPROTO *file = conn->data->state.proto.file;
+ struct FILEPROTO *file = conn->data->req.protop;
const char *dir = strchr(file->path, DIRSEP);
int fd;
int mode;
curl_off_t bytecount = 0;
int fd;
struct timeval now = Curl_tvnow();
+ struct FILEPROTO *file;
*done = TRUE; /* unconditionally */
if(data->set.upload)
return file_upload(conn);
+ file = conn->data->req.protop;
+
/* get the fd from the connection phase */
- fd = data->state.proto.file->fd;
+ fd = file->fd;
/* VMS: This only works reliable for STREAMLF files */
if(-1 != fstat(fd, &statbuf)) {
static CURLcode InitiateTransfer(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
CURLcode result = CURLE_OK;
if(conn->ssl[SECONDARYSOCKET].use) {
static CURLcode ftp_state_user(struct connectdata *conn)
{
CURLcode result;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
/* send USER */
PPSENDF(&conn->proto.ftpc.pp, "USER %s", ftp->user?ftp->user:"");
static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data;
if(ftp->transfer != FTPTRANSFER_BODY) {
static CURLcode ftp_state_rest(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if((ftp->transfer != FTPTRANSFER_BODY) && ftpc->file) {
static CURLcode ftp_state_size(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if((ftp->transfer == FTPTRANSFER_INFO) && ftpc->file) {
static CURLcode ftp_state_type(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
bool sizechecked)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
int seekerr = CURL_SEEKFUNC_OK;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
bool quote=FALSE;
struct curl_slist *item;
* FTP pointer
*/
struct HTTP http_proxy;
- struct FTP *ftp_save = data->state.proto.ftp;
+ struct FTP *ftp_save = data->req.protop;
memset(&http_proxy, 0, sizeof(http_proxy));
- data->state.proto.http = &http_proxy;
+ data->req.protop = &http_proxy;
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
- data->state.proto.ftp = ftp_save;
+ data->req.protop = ftp_save;
if(result)
return result;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
switch(ftpcode) {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
char *buf = data->state.buffer;
if((ftpcode == 150) || (ftpcode == 125)) {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
(void)instate; /* no use for this yet */
bool premature)
{
struct SessionHandle *data = conn->data;
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
ssize_t nread;
bool complete = FALSE;
/* the ftp struct is inited in ftp_connect() */
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
/* if the second connection isn't done yet, wait for it */
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
if(conn->data->set.opt_no_body) {
/* requested no body means no transfer... */
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
ftp->transfer = FTPTRANSFER_INFO;
}
{
struct SessionHandle *data = conn->data;
/* the ftp struct is already inited in ftp_connect() */
- struct FTP *ftp = data->state.proto.ftp;
+ struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
const char *slash_pos; /* position of the first '/' char in curpos */
const char *path_to_use = data->state.path;
static CURLcode ftp_dophase_done(struct connectdata *conn,
bool connected)
{
- struct FTP *ftp = conn->data->state.proto.ftp;
+ struct FTP *ftp = conn->data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if(connected) {
#endif
}
- conn->data->state.proto.ftp = ftp = malloc(sizeof(struct FTP));
+ conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
if(NULL == ftp)
return CURLE_OUT_OF_MEMORY;
{
/* allocate the HTTP-specific struct for the SessionHandle, only to survive
during this request */
- struct HTTP *http;
-
- DEBUGASSERT(conn->data->state.proto.http == NULL);
+ DEBUGASSERT(conn->data->req.protop == NULL);
- conn->data->state.proto.http = http = calloc(1, sizeof(struct HTTP));
- if(!http)
+ conn->data->req.protop = calloc(1, sizeof(struct HTTP));
+ if(!conn->data->req.protop)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
static CURLcode http_perhapsrewind(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
- struct HTTP *http = data->state.proto.http;
+ struct HTTP *http = data->req.protop;
curl_off_t bytessent;
curl_off_t expectsend = -1; /* default is unknown */
void *userp)
{
struct connectdata *conn = (struct connectdata *)userp;
- struct HTTP *http = conn->data->state.proto.http;
+ struct HTTP *http = conn->data->req.protop;
size_t fullsize = size * nitems;
if(0 == http->postsize)
CURLcode res;
char *ptr;
size_t size;
- struct HTTP *http = conn->data->state.proto.http;
+ struct HTTP *http = conn->data->req.protop;
size_t sendsize;
curl_socket_t sockfd;
size_t headersize;
CURLcode status, bool premature)
{
struct SessionHandle *data = conn->data;
- struct HTTP *http =data->state.proto.http;
+ struct HTTP *http =data->req.protop;
Curl_unencode_cleanup(conn);
the rest of the request in the PERFORM phase. */
*done = TRUE;
- http = data->state.proto.http;
+ http = data->req.protop;
if(!data->state.this_is_a_follow) {
/* this is not a followed location, get the original host name */
* This function might be called several times in the multi interface case
* if the proxy's CONNTECT response is not instant.
*/
- prot_save = conn->data->state.proto.generic;
+ prot_save = conn->data->req.protop;
memset(&http_proxy, 0, sizeof(http_proxy));
- conn->data->state.proto.http = &http_proxy;
+ conn->data->req.protop = &http_proxy;
conn->bits.close = FALSE;
result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
conn->host.name, conn->remote_port);
- conn->data->state.proto.generic = prot_save;
+ conn->data->req.protop = prot_save;
if(CURLE_OK != result)
return result;
#else
static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
int *resp)
{
- struct IMAP *imap = conn->data->state.proto.imap;
+ struct IMAP *imap = conn->data->req.protop;
struct imap_conn *imapc = &conn->proto.imapc;
const char *id = imapc->resptag;
size_t id_len = strlen(id);
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
char *mailbox;
if(imap->custom)
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
struct imap_conn *imapc = &conn->proto.imapc;
char *mailbox;
static CURLcode imap_perform_fetch(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct IMAP *imap = conn->data->state.proto.imap;
+ struct IMAP *imap = conn->data->req.protop;
/* Check we have a UID */
if(!imap->uid) {
static CURLcode imap_perform_append(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct IMAP *imap = conn->data->state.proto.imap;
+ struct IMAP *imap = conn->data->req.protop;
char *mailbox;
/* Check we have a mailbox */
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = conn->data->state.proto.imap;
+ struct IMAP *imap = conn->data->req.protop;
struct imap_conn *imapc = &conn->proto.imapc;
const char *line = data->state.buffer;
char tmp[20];
struct SessionHandle *data = conn->data;
struct IMAP *imap;
- imap = data->state.proto.imap = calloc(sizeof(struct IMAP), 1);
+ imap = data->req.protop = calloc(sizeof(struct IMAP), 1);
if(!imap)
result = CURLE_OUT_OF_MEMORY;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
(void)premature;
/* This is IMAP and no proxy */
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
struct imap_conn *imapc = &conn->proto.imapc;
bool selected = FALSE;
/* Call this when the DO phase has completed */
static CURLcode imap_dophase_done(struct connectdata *conn, bool connected)
{
- struct IMAP *imap = conn->data->state.proto.imap;
+ struct IMAP *imap = conn->data->req.protop;
(void)connected;
/* The imap struct is already initialised in imap_connect() */
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
const char *begin = data->state.path;
const char *ptr = begin;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap = data->req.protop;
const char *custom = data->set.str[STRING_CUSTOMREQUEST];
if(custom) {
if(!lr)
return CURLE_OUT_OF_MEMORY;
lr->msgid = msgid;
- data->state.proto.generic = lr;
+ data->req.protop = lr;
Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);
*done = TRUE;
return CURLE_OK;
static CURLcode ldap_done(struct connectdata *conn, CURLcode res,
bool premature)
{
- ldapreqinfo *lr = conn->data->state.proto.generic;
+ ldapreqinfo *lr = conn->data->req.protop;
(void)res;
(void)premature;
ldap_abandon_ext(li->ld, lr->msgid, NULL, NULL);
lr->msgid = 0;
}
- conn->data->state.proto.generic = NULL;
+ conn->data->req.protop = NULL;
free(lr);
}
return CURLE_OK;
{
ldapconninfo *li = conn->proto.generic;
struct SessionHandle *data=conn->data;
- ldapreqinfo *lr = data->state.proto.generic;
+ ldapreqinfo *lr = data->req.protop;
int rc, ret;
LDAPMessage *result = NULL;
LDAPMessage *ent;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct POP3 *pop3 = data->state.proto.pop3;
+ struct POP3 *pop3 = data->req.protop;
const char *command = NULL;
/* Calculate the default command */
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct POP3 *pop3 = data->state.proto.pop3;
+ struct POP3 *pop3 = data->req.protop;
struct pop3_conn *pop3c = &conn->proto.pop3c;
struct pingpong *pp = &pop3c->pp;
struct SessionHandle *data = conn->data;
struct POP3 *pop3;
- pop3 = data->state.proto.pop3 = calloc(sizeof(struct POP3), 1);
+ pop3 = data->req.protop = calloc(sizeof(struct POP3), 1);
if(!pop3)
result = CURLE_OUT_OF_MEMORY;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct POP3 *pop3 = data->state.proto.pop3;
+ struct POP3 *pop3 = data->req.protop;
(void)premature;
if(conn->data->set.opt_no_body) {
/* Requested no body means no transfer */
- struct POP3 *pop3 = conn->data->state.proto.pop3;
+ struct POP3 *pop3 = conn->data->req.protop;
pop3->transfer = FTPTRANSFER_INFO;
}
{
/* The POP3 struct is already initialised in pop3_connect() */
struct SessionHandle *data = conn->data;
- struct POP3 *pop3 = data->state.proto.pop3;
+ struct POP3 *pop3 = data->req.protop;
const char *path = data->state.path;
/* URL decode the path for the message ID */
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct POP3 *pop3 = data->state.proto.pop3;
+ struct POP3 *pop3 = data->req.protop;
const char *custom = data->set.str[STRING_CUSTOMREQUEST];
/* URL decode the custom request */
{
struct RTSP *rtsp;
- conn->data->state.proto.rtsp = rtsp = calloc(1, sizeof(struct RTSP));
+ conn->data->req.protop = rtsp = calloc(1, sizeof(struct RTSP));
if(!rtsp)
return CURLE_OUT_OF_MEMORY;
CURLcode status, bool premature)
{
struct SessionHandle *data = conn->data;
- struct RTSP *rtsp = data->state.proto.rtsp;
+ struct RTSP *rtsp = data->req.protop;
CURLcode httpStatus;
long CSeq_sent;
long CSeq_recv;
struct SessionHandle *data = conn->data;
CURLcode result=CURLE_OK;
Curl_RtspReq rtspreq = data->set.rtspreq;
- struct RTSP *rtsp = data->state.proto.rtsp;
+ struct RTSP *rtsp = data->req.protop;
struct HTTP *http;
Curl_send_buffer *req_buffer;
curl_off_t postsize = 0; /* for ANNOUNCE and SET_PARAMETER */
/* Store the received CSeq. Match is verified in rtsp_done */
int nc = sscanf(&header[4], ": %ld", &CSeq);
if(nc == 1) {
- data->state.proto.rtsp->CSeq_recv = CSeq; /* mark the request */
+ struct RTSP *rtsp = data->req.protop;
+ rtsp->CSeq_recv = CSeq; /* mark the request */
data->state.rtsp_CSeq_recv = CSeq; /* update the handle */
}
else {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct SMTP *smtp = data->state.proto.smtp;
+ struct SMTP *smtp = data->req.protop;
/* Send the RCPT TO command */
if(smtp->rcpt) {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct SMTP *smtp = data->state.proto.smtp;
+ struct SMTP *smtp = data->req.protop;
(void)instate; /* no use for this yet */
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct SMTP *smtp = data->state.proto.smtp;
+ struct SMTP *smtp = data->req.protop;
(void)instate; /* no use for this yet */
struct SessionHandle *data = conn->data;
struct SMTP *smtp;
- smtp = data->state.proto.smtp = calloc(sizeof(struct SMTP), 1);
+ smtp = data->req.protop = calloc(sizeof(struct SMTP), 1);
if(!smtp)
result = CURLE_OUT_OF_MEMORY;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct SMTP *smtp = data->state.proto.smtp;
+ struct SMTP *smtp = data->req.protop;
struct pingpong *pp = &conn->proto.smtpc.pp;
const char *eob;
ssize_t len;
if(conn->data->set.opt_no_body) {
/* Requested no body means no transfer */
- struct SMTP *smtp = conn->data->state.proto.smtp;
+ struct SMTP *smtp = conn->data->req.protop;
smtp->transfer = FTPTRANSFER_INFO;
}
/* Call this when the DO phase has completed */
static CURLcode smtp_dophase_done(struct connectdata *conn, bool connected)
{
- struct SMTP *smtp = conn->data->state.proto.smtp;
+ struct SMTP *smtp = conn->data->req.protop;
(void)connected;
ssize_t i;
ssize_t si;
struct SessionHandle *data = conn->data;
- struct SMTP *smtp = data->state.proto.smtp;
+ struct SMTP *smtp = data->req.protop;
/* Do we need to allocate the scatch buffer? */
if(!data->state.scratch) {
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct SSHPROTO *sftp_scp = data->state.proto.ssh;
+ struct SSHPROTO *sftp_scp = data->req.protop;
struct ssh_conn *sshc = &conn->proto.sshc;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
char *new_readdir_line;
{
struct SSHPROTO *ssh;
- conn->data->state.proto.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
+ conn->data->req.protop = ssh = calloc(1, sizeof(struct SSHPROTO));
if(!ssh)
return CURLE_OUT_OF_MEMORY;
struct ssh_conn *ssh = &conn->proto.sshc;
(void) dead_connection;
- Curl_safefree(conn->data->state.proto.ssh);
+ Curl_safefree(conn->data->req.protop);
if(ssh->ssh_session) {
/* only if there's a session still around to use! */
static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
{
CURLcode result = CURLE_OK;
- struct SSHPROTO *sftp_scp = conn->data->state.proto.ssh;
+ struct SSHPROTO *sftp_scp = conn->data->req.protop;
if(status == CURLE_OK) {
/* run the state-machine
DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n"));
- Curl_safefree(conn->data->state.proto.ssh);
+ Curl_safefree(conn->data->req.protop);
if(conn->proto.sshc.ssh_session) {
/* only if there's a session still around to use! */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
if(!tn)
return CURLE_OUT_OF_MEMORY;
- conn->data->state.proto.telnet = (void *)tn; /* make us known */
+ conn->data->req.protop = tn; /* make us known */
tn->telrcv_state = CURL_TS_DATA;
static void negotiate(struct connectdata *conn)
{
int i;
- struct TELNET *tn = (struct TELNET *) conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *) conn->data->req.protop;
for(i = 0;i < CURL_NTELOPTS;i++) {
if(i==CURL_TELOPT_ECHO)
static
void set_remote_option(struct connectdata *conn, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
if(newstate == CURL_YES) {
switch(tn->him[option]) {
case CURL_NO:
static
void rec_will(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
switch(tn->him[option]) {
case CURL_NO:
if(tn->him_preferred[option] == CURL_YES) {
static
void rec_wont(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
switch(tn->him[option]) {
case CURL_NO:
/* Already disabled */
static void
set_local_option(struct connectdata *conn, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
if(newstate == CURL_YES) {
switch(tn->us[option]) {
case CURL_NO:
static
void rec_do(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
switch(tn->us[option]) {
case CURL_NO:
if(tn->us_preferred[option] == CURL_YES) {
static
void rec_dont(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
switch(tn->us[option]) {
case CURL_NO:
/* Already disabled */
char option_keyword[128];
char option_arg[256];
struct SessionHandle *data = conn->data;
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
CURLcode result = CURLE_OK;
int binary_option;
char varname[128];
char varval[128];
struct SessionHandle *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.protop;
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2);
switch (CURL_SB_GET(tn)) {
unsigned char*uc1, *uc2;
struct SessionHandle *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.protop;
switch (option) {
case CURL_TELOPT_NAWS:
int in = 0;
int startwrite=-1;
struct SessionHandle *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.protop;
#define startskipping() \
if(startwrite >= 0) { \
static CURLcode telnet_done(struct connectdata *conn,
CURLcode status, bool premature)
{
- struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.protop;
(void)status; /* unused */
(void)premature; /* not used */
curl_slist_free_all(tn->telnet_vars);
tn->telnet_vars = NULL;
- Curl_safefree(conn->data->state.proto.telnet);
+ Curl_safefree(conn->data->req.protop);
return CURLE_OK;
}
if(code)
return code;
- tn = (struct TELNET *)data->state.proto.telnet;
+ tn = (struct TELNET *)data->req.protop;
code = check_telnet_options(conn);
if(code)
/* HTTP pollution, this should be written nicer to become more
protocol agnostic. */
int fillcount;
+ struct HTTP *http = data->req.protop;
if((k->exp100 == EXP100_SENDING_REQUEST) &&
- (data->state.proto.http->sending == HTTPSEND_BODY)) {
+ (http->sending == HTTPSEND_BODY)) {
/* If this call is to send body data, we must take some action:
We have sent off the full HTTP 1.1 request, and we shall now
go into the Expect: 100 state and await such a header */
}
if(conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_RTSP)) {
- if(data->state.proto.http->sending == HTTPSEND_REQUEST)
+ if(http->sending == HTTPSEND_REQUEST)
/* We're sending the HTTP request headers, not the data.
Remember that so we don't change the line endings. */
sending_http_headers = TRUE;
data->req.headerbytecount == 0) &&
conn->bits.reuse &&
!data->set.opt_no_body &&
- data->set.rtspreq != RTSPREQ_RECEIVE)) {
+ data->set.rtspreq != RTSPREQ_RECEIVE)) {
/* We got no data, we attempted to re-use a connection and yet we want a
"body". This might happen if the connection was left alive when we were
done using it before, but that was closed when we wanted to read from
transferred! */
- if((conn->handler->protocol&CURLPROTO_HTTP) &&
- data->state.proto.http->writebytecount)
- return Curl_readrewind(conn);
+ if(conn->handler->protocol&CURLPROTO_HTTP) {
+ struct HTTP *http = data->req.protop;
+ if(http->writebytecount)
+ return Curl_readrewind(conn);
+ }
}
return CURLE_OK;
}
k->keepon |= KEEP_RECV;
if(conn->writesockfd != CURL_SOCKET_BAD) {
+ struct HTTP *http = data->req.protop;
/* HTTP 1.1 magic:
Even if we require a 100-return code before uploading data, we might
state info where we wait for the 100-return code
*/
if((data->state.expect100header) &&
- (data->state.proto.http->sending == HTTPSEND_BODY)) {
+ (conn->handler->protocol&CURLPROTO_HTTP) &&
+ (http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->exp100 = EXP100_AWAITING_CONTINUE;
k->start100 = Curl_tvnow();
static CURLcode parse_login_details(const char *login, const size_t len,
char **userptr, char **passwdptr,
char **optionsptr);
-static void free_connection_internals(struct SessionHandle *data);
/*
* Protocol table.
*/
data->state.path = NULL;
/* freed here just in case DONE wasn't called */
- free_connection_internals(data);
+ Curl_free_request_state(data);
/* Close down all open SSL info and sessions */
Curl_ssl_close_all(data);
without doing a DISCONNECT or DONE in between (since the connection is
yet in place) and therefore this function needs to first make sure
there's no lingering previous data allocated. */
- free_connection_internals(conn->data);
+ Curl_free_request_state(conn->data);
+
+ memset(&conn->data->req, 0, sizeof(struct SingleRequest));
+ conn->data->req.maxdownload = -1;
conn->socktype = SOCK_STREAM; /* most of them are TCP streams */
return CURLE_OK;
}
-static void free_connection_internals(struct SessionHandle *data)
+/*
+ * Curl_free_request_state() should free temp data that was allocated in the
+ * SessionHandle for this single request.
+ */
+
+void Curl_free_request_state(struct SessionHandle *data)
{
- Curl_safefree(data->state.proto.generic);
+ Curl_safefree(data->req.protop);
}
this was either closed or handed over to the connection
cache here, and therefore cannot be used from this point on
*/
- free_connection_internals(data);
+ Curl_free_request_state(data);
return result;
}
CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done);
CURLcode Curl_setup_conn(struct connectdata *conn,
bool *protocol_done);
+void Curl_free_request_state(struct SessionHandle *data);
int Curl_protocol_getsock(struct connectdata *conn,
curl_socket_t *socks,
bool forbidchunk; /* used only to explicitly forbid chunk-upload for
specific upload buffers. See readmoredata() in
http.c for details. */
+
+ void *protop; /* Allocated protocol-specific data. Each protocol
+ handler makes sure this points to data it needs. */
};
/*
long rtsp_next_server_CSeq; /* the session's next server CSeq */
long rtsp_CSeq_recv; /* most recent CSeq received */
- /* Protocol specific data.
- *
- *************************************************************************
- * Note that this data will be freed after each request is DONE, so anything
- * that should be kept/stored on a per-connection basis and thus live for
- * the next request on the same connection MUST be put in the connectdata
- * struct!
- *************************************************************************/
- union {
- struct HTTP *http;
- struct HTTP *https; /* alias, just for the sake of being more readable */
- struct RTSP *rtsp;
- struct FTP *ftp;
- /* void *tftp; not used */
- struct FILEPROTO *file;
- void *telnet; /* private for telnet.c-eyes only */
- void *generic;
- struct SSHPROTO *ssh;
- struct IMAP *imap;
- struct POP3 *pop3;
- struct SMTP *smtp;
- } proto;
-
/* if true, force SSL connection retry (workaround for certain servers) */
bool ssl_connect_retry;
};