diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-11-24 23:16:55 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-11-24 23:16:55 +0000 |
commit | 13648f8ccda6f99674ac407640474634e856804c (patch) | |
tree | 9ce7e3edb2ade2f936428e584813b61285656fcf /lib | |
parent | 5b809a31047111dab9dd11f48f2bb7db00f0e23e (diff) |
struct HandleData is now called struct SingleRequest, and is only for data that
is inited at the start of the DO action. I removed the Curl_transfer_keeper
struct completely, and I had to move out a few struct members (that had to
be set before DO or used after DONE) to the UrlState struct. The SingleRequest
struct is accessed with SessionHandle->req.
One of the biggest reasons for doing this was the bunch of duplicate struct
members in HandleData and Curl_transfer_keeper since it was really messy to
keep track of two variables with the same name and basically the same purpose!
Diffstat (limited to 'lib')
-rw-r--r-- | lib/content_encoding.c | 6 | ||||
-rw-r--r-- | lib/content_encoding.h | 6 | ||||
-rw-r--r-- | lib/dict.c | 4 | ||||
-rw-r--r-- | lib/easy.c | 12 | ||||
-rw-r--r-- | lib/file.c | 46 | ||||
-rw-r--r-- | lib/ftp.c | 157 | ||||
-rw-r--r-- | lib/http.c | 132 | ||||
-rw-r--r-- | lib/http_chunks.c | 16 | ||||
-rw-r--r-- | lib/multi.c | 12 | ||||
-rw-r--r-- | lib/progress.c | 7 | ||||
-rw-r--r-- | lib/ssh.c | 38 | ||||
-rw-r--r-- | lib/telnet.c | 30 | ||||
-rw-r--r-- | lib/tftp.c | 20 | ||||
-rw-r--r-- | lib/transfer.c | 110 | ||||
-rw-r--r-- | lib/url.c | 86 | ||||
-rw-r--r-- | lib/urldata.h | 152 |
16 files changed, 398 insertions, 436 deletions
diff --git a/lib/content_encoding.c b/lib/content_encoding.c index bde84570f..1d2852b5a 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -77,7 +77,7 @@ exit_zlib(z_stream *z, zlibInitState *zlib_init, CURLcode result) static CURLcode inflate_stream(struct connectdata *conn, - struct Curl_transfer_keeper *k) + struct SingleRequest *k) { int allow_restart = 1; z_stream *z = &k->z; /* zlib state structure */ @@ -152,7 +152,7 @@ inflate_stream(struct connectdata *conn, CURLcode Curl_unencode_deflate_write(struct connectdata *conn, - struct Curl_transfer_keeper *k, + struct SingleRequest *k, ssize_t nread) { z_stream *z = &k->z; /* zlib state structure */ @@ -265,7 +265,7 @@ static enum { CURLcode Curl_unencode_gzip_write(struct connectdata *conn, - struct Curl_transfer_keeper *k, + struct SingleRequest *k, ssize_t nread) { z_stream *z = &k->z; /* zlib state structure */ diff --git a/lib/content_encoding.h b/lib/content_encoding.h index b31669be4..e654318f1 100644 --- a/lib/content_encoding.h +++ b/lib/content_encoding.h @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2007, 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 @@ -32,10 +32,10 @@ #endif CURLcode Curl_unencode_deflate_write(struct connectdata *conn, - struct Curl_transfer_keeper *k, + struct SingleRequest *req, ssize_t nread); CURLcode Curl_unencode_gzip_write(struct connectdata *conn, - struct Curl_transfer_keeper *k, + struct SingleRequest *k, ssize_t nread); diff --git a/lib/dict.c b/lib/dict.c index dc078ff38..0838909bd 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -155,8 +155,8 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done) struct SessionHandle *data=conn->data; curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; - char *path = data->reqdata.path; - curl_off_t *bytecount = &data->reqdata.keep.bytecount; + char *path = data->state.path; + curl_off_t *bytecount = &data->req.bytecount; *done = TRUE; /* unconditionally */ diff --git a/lib/easy.c b/lib/easy.c index e068dc693..adc88ec2f 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -528,9 +528,9 @@ void Curl_easy_addmulti(struct SessionHandle *data, void Curl_easy_initHandleData(struct SessionHandle *data) { - memset(&data->reqdata, 0, sizeof(struct HandleData)); + memset(&data->req, 0, sizeof(struct SingleRequest)); - data->reqdata.maxdownload = -1; + data->req.maxdownload = -1; } /* @@ -676,11 +676,11 @@ void curl_easy_reset(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; - Curl_safefree(data->reqdata.pathbuffer); - data->reqdata.pathbuffer=NULL; + Curl_safefree(data->state.pathbuffer); + data->state.pathbuffer=NULL; - Curl_safefree(data->reqdata.proto.generic); - data->reqdata.proto.generic=NULL; + Curl_safefree(data->state.proto.generic); + data->state.proto.generic=NULL; /* zero out UserDefined data: */ Curl_freeset(data); diff --git a/lib/file.c b/lib/file.c index 1461de224..6a8e1de49 100644 --- a/lib/file.c +++ b/lib/file.c @@ -127,7 +127,7 @@ const struct Curl_handler Curl_handler_file = { static CURLcode Curl_file_connect(struct connectdata *conn, bool *done) { struct SessionHandle *data = conn->data; - char *real_path = curl_easy_unescape(data, data->reqdata.path, 0, NULL); + char *real_path = curl_easy_unescape(data, data->state.path, 0, NULL); struct FILEPROTO *file; int fd; #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) @@ -142,17 +142,17 @@ static CURLcode Curl_file_connect(struct connectdata *conn, bool *done) sessionhandle, deal with it */ Curl_reset_reqproto(conn); - if(!data->reqdata.proto.file) { + if(!data->state.proto.file) { file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1); if(!file) { free(real_path); return CURLE_OUT_OF_MEMORY; } - data->reqdata.proto.file = file; + data->state.proto.file = file; } else { /* file is not a protocol that can deal with "persistancy" */ - file = data->reqdata.proto.file; + file = data->state.proto.file; Curl_safefree(file->freepath); if(file->fd != -1) close(file->fd); @@ -200,7 +200,7 @@ static CURLcode Curl_file_connect(struct connectdata *conn, bool *done) file->fd = fd; if(!data->set.upload && (fd == -1)) { - failf(data, "Couldn't open file %s", data->reqdata.path); + failf(data, "Couldn't open file %s", data->state.path); Curl_file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE); return CURLE_FILE_COULDNT_READ_FILE; } @@ -212,7 +212,7 @@ static CURLcode Curl_file_connect(struct connectdata *conn, bool *done) static CURLcode Curl_file_done(struct connectdata *conn, CURLcode status, bool premature) { - struct FILEPROTO *file = conn->data->reqdata.proto.file; + struct FILEPROTO *file = conn->data->state.proto.file; (void)status; /* not used */ (void)premature; /* not used */ Curl_safefree(file->freepath); @@ -231,7 +231,7 @@ static CURLcode Curl_file_done(struct connectdata *conn, static CURLcode file_upload(struct connectdata *conn) { - struct FILEPROTO *file = conn->data->reqdata.proto.file; + struct FILEPROTO *file = conn->data->state.proto.file; const char *dir = strchr(file->path, DIRSEP); FILE *fp; CURLcode res=CURLE_OK; @@ -250,7 +250,7 @@ static CURLcode file_upload(struct connectdata *conn) */ conn->fread_func = data->set.fread_func; conn->fread_in = data->set.in; - conn->data->reqdata.upload_fromhere = buf; + conn->data->req.upload_fromhere = buf; if(!dir) return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ @@ -258,7 +258,7 @@ static CURLcode file_upload(struct connectdata *conn) if(!dir[1]) return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ - if(data->reqdata.resume_from) + if(data->state.resume_from) fp = fopen( file->path, "ab" ); else { int fd; @@ -287,14 +287,14 @@ static CURLcode file_upload(struct connectdata *conn) Curl_pgrsSetUploadSize(data, data->set.infilesize); /* treat the negative resume offset value as the case of "-" */ - if(data->reqdata.resume_from < 0){ + if(data->state.resume_from < 0){ if(stat(file->path, &file_stat)){ fclose(fp); failf(data, "Can't get the size of %s", file->path); return CURLE_WRITE_ERROR; } else - data->reqdata.resume_from = (curl_off_t)file_stat.st_size; + data->state.resume_from = (curl_off_t)file_stat.st_size; } while(res == CURLE_OK) { @@ -309,16 +309,16 @@ static CURLcode file_upload(struct connectdata *conn) nread = (size_t)readcount; /*skip bytes before resume point*/ - if(data->reqdata.resume_from) { - if( (curl_off_t)nread <= data->reqdata.resume_from ) { - data->reqdata.resume_from -= nread; + if(data->state.resume_from) { + if( (curl_off_t)nread <= data->state.resume_from ) { + data->state.resume_from -= nread; nread = 0; buf2 = buf; } else { - buf2 = buf + data->reqdata.resume_from; - nread -= data->reqdata.resume_from; - data->reqdata.resume_from = 0; + buf2 = buf + data->state.resume_from; + nread -= data->state.resume_from; + data->state.resume_from = 0; } } else @@ -385,7 +385,7 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done) return file_upload(conn); /* get the fd from the connection phase */ - fd = conn->data->reqdata.proto.file->fd; + fd = conn->data->state.proto.file->fd; /* VMS: This only works reliable for STREAMLF files */ if( -1 != fstat(fd, &statbuf)) { @@ -434,8 +434,8 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done) return result; } - if(data->reqdata.resume_from <= expected_size) - expected_size -= data->reqdata.resume_from; + if(data->state.resume_from <= expected_size) + expected_size -= data->state.resume_from; else { failf(data, "failed to resume file:// transfer"); return CURLE_BAD_DOWNLOAD_RESUME; @@ -451,9 +451,9 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done) if(fstated) Curl_pgrsSetDownloadSize(data, expected_size); - if(data->reqdata.resume_from) { - if(data->reqdata.resume_from != - lseek(fd, data->reqdata.resume_from, SEEK_SET)) + if(data->state.resume_from) { + if(data->state.resume_from != + lseek(fd, data->state.resume_from, SEEK_SET)) return CURLE_BAD_DOWNLOAD_RESUME; } @@ -482,7 +482,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd, int clipamount = 0; bool restart = FALSE; - data->reqdata.keep.headerbytecount += gotbytes; + data->req.headerbytecount += gotbytes; ftpc->nread_resp += gotbytes; for(i = 0; i < gotbytes; ptr++, i++) { @@ -788,7 +788,7 @@ static void state(struct connectdata *conn, static CURLcode ftp_state_user(struct connectdata *conn) { CURLcode result; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; /* send USER */ NBFTPSENDF(conn, "USER %s", ftp->user?ftp->user:""); @@ -1313,7 +1313,7 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn) static CURLcode ftp_state_post_rest(struct connectdata *conn) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct SessionHandle *data = conn->data; if(ftp->transfer != FTPTRANSFER_BODY) { @@ -1337,7 +1337,7 @@ static CURLcode ftp_state_post_rest(struct connectdata *conn) static CURLcode ftp_state_post_size(struct connectdata *conn) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; if((ftp->transfer != FTPTRANSFER_BODY) && ftpc->file) { @@ -1358,7 +1358,7 @@ static CURLcode ftp_state_post_size(struct connectdata *conn) static CURLcode ftp_state_post_type(struct connectdata *conn) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; if((ftp->transfer == FTPTRANSFER_INFO) && ftpc->file) { @@ -1398,11 +1398,11 @@ static CURLcode ftp_state_post_listtype(struct connectdata *conn) lstArg = NULL; if((data->set.ftp_filemethod == FTPFILE_NOCWD) && - data->reqdata.path && - data->reqdata.path[0] && - strchr(data->reqdata.path,'/')) { + data->state.path && + data->state.path[0] && + strchr(data->state.path,'/')) { - lstArg = strdup(data->reqdata.path); + lstArg = strdup(data->state.path); if(!lstArg) return CURLE_OUT_OF_MEMORY; @@ -1465,7 +1465,7 @@ static CURLcode ftp_state_post_stortype(struct connectdata *conn) static CURLcode ftp_state_post_mdtm(struct connectdata *conn) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct SessionHandle *data = conn->data; struct ftp_conn *ftpc = &conn->proto.ftpc; @@ -1522,13 +1522,13 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, bool sizechecked) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct SessionHandle *data = conn->data; struct ftp_conn *ftpc = &conn->proto.ftpc; curl_off_t passed=0; - if((data->reqdata.resume_from && !sizechecked) || - ((data->reqdata.resume_from > 0) && sizechecked)) { + if((data->state.resume_from && !sizechecked) || + ((data->state.resume_from > 0) && sizechecked)) { /* we're about to continue the uploading of a file */ /* 1. get already existing file's size. We use the SIZE command for this which may not exist in the server! The SIZE command is not in @@ -1542,7 +1542,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, /* 4. lower the infilesize counter */ /* => transfer as usual */ - if(data->reqdata.resume_from < 0 ) { + if(data->state.resume_from < 0 ) { /* Got no given size to start from, figure it out */ NBFTPSENDF(conn, "SIZE %s", ftpc->file); state(conn, FTP_STOR_SIZE); @@ -1559,7 +1559,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, /* TODO: allow the ioctlfunction to provide a fast forward function that can be used here and use this method only as a fallback! */ do { - curl_off_t readthisamountnow = (data->reqdata.resume_from - passed); + curl_off_t readthisamountnow = (data->state.resume_from - passed); curl_off_t actuallyread; if(readthisamountnow > BUFSIZE) @@ -1575,11 +1575,11 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, " bytes from the input", passed); return CURLE_FTP_COULDNT_USE_REST; } - } while(passed != data->reqdata.resume_from); + } while(passed != data->state.resume_from); /* now, decrease the size of the read */ if(data->set.infilesize>0) { - data->set.infilesize -= data->reqdata.resume_from; + data->set.infilesize -= data->state.resume_from; if(data->set.infilesize <= 0) { infof(data, "File already completely uploaded\n"); @@ -1612,7 +1612,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; bool quote=FALSE; struct curl_slist *item; @@ -1907,13 +1907,13 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, * FTP pointer */ struct HTTP http_proxy; - struct FTP *ftp_save = data->reqdata.proto.ftp; + struct FTP *ftp_save = data->state.proto.ftp; memset(&http_proxy, 0, sizeof(http_proxy)); - data->reqdata.proto.http = &http_proxy; + data->state.proto.http = &http_proxy; result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport); - data->reqdata.proto.ftp = ftp_save; + data->state.proto.ftp = ftp_save; if(CURLE_OK != result) return result; @@ -1963,7 +1963,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data=conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; switch(ftpcode) { @@ -2095,7 +2095,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data=conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; if(data->set.max_filesize && (filesize > data->set.max_filesize)) { @@ -2104,7 +2104,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn, } ftp->downloadsize = filesize; - if(data->reqdata.resume_from) { + if(data->state.resume_from) { /* We always (attempt to) get the size of downloads, so it is done before this even when not doing resumes. */ if(filesize == -1) { @@ -2117,28 +2117,28 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn, else { /* We got a file size report, so we check that there actually is a part of the file left to get, or else we go home. */ - if(data->reqdata.resume_from< 0) { + if(data->state.resume_from< 0) { /* We're supposed to download the last abs(from) bytes */ - if(filesize < -data->reqdata.resume_from) { + if(filesize < -data->state.resume_from) { failf(data, "Offset (%" FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")", - data->reqdata.resume_from, filesize); + data->state.resume_from, filesize); return CURLE_BAD_DOWNLOAD_RESUME; } /* convert to size to download */ - ftp->downloadsize = -data->reqdata.resume_from; + ftp->downloadsize = -data->state.resume_from; /* download from where? */ - data->reqdata.resume_from = filesize - ftp->downloadsize; + data->state.resume_from = filesize - ftp->downloadsize; } else { - if(filesize < data->reqdata.resume_from) { + if(filesize < data->state.resume_from) { failf(data, "Offset (%" FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")", - data->reqdata.resume_from, filesize); + data->state.resume_from, filesize); return CURLE_BAD_DOWNLOAD_RESUME; } /* Now store the number of bytes we are expected to download */ - ftp->downloadsize = filesize-data->reqdata.resume_from; + ftp->downloadsize = filesize-data->state.resume_from; } } @@ -2156,9 +2156,9 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn, /* Set resume file transfer offset */ infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T - "\n", data->reqdata.resume_from); + "\n", data->state.resume_from); - NBFTPSENDF(conn, "REST %" FORMAT_OFF_T, data->reqdata.resume_from); + NBFTPSENDF(conn, "REST %" FORMAT_OFF_T, data->state.resume_from); state(conn, FTP_RETR_REST); @@ -2202,7 +2202,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn, result = ftp_state_post_retr_size(conn, filesize); } else if(instate == FTP_STOR_SIZE) { - data->reqdata.resume_from = filesize; + data->state.resume_from = filesize; result = ftp_state_ul_setup(conn, TRUE); } @@ -2250,7 +2250,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; if(ftpcode>=400) { failf(data, "Failed FTP upload: %0d", ftpcode); @@ -2297,7 +2297,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; char *buf = data->state.buffer; if((ftpcode == 150) || (ftpcode == 125)) { @@ -2384,10 +2384,10 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, return result; } - if(size > data->reqdata.maxdownload && data->reqdata.maxdownload > 0) - size = data->reqdata.size = data->reqdata.maxdownload; + if(size > data->req.maxdownload && data->req.maxdownload > 0) + size = data->req.size = data->req.maxdownload; - infof(data, "Maxdownload = %" FORMAT_OFF_T "\n", data->reqdata.maxdownload); + infof(data, "Maxdownload = %" FORMAT_OFF_T "\n", data->req.maxdownload); if(instate != FTP_LIST) infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size); @@ -2465,7 +2465,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; (void)instate; /* no use for this yet */ @@ -3009,17 +3009,17 @@ static CURLcode ftp_init(struct connectdata *conn) { struct SessionHandle *data = conn->data; struct FTP *ftp; - if(data->reqdata.proto.ftp) + if(data->state.proto.ftp) return CURLE_OK; ftp = (struct FTP *)calloc(sizeof(struct FTP), 1); if(!ftp) return CURLE_OUT_OF_MEMORY; - data->reqdata.proto.ftp = ftp; + data->state.proto.ftp = ftp; /* get some initial data into the ftp struct */ - ftp->bytecountp = &data->reqdata.keep.bytecount; + ftp->bytecountp = &data->req.bytecount; /* no need to duplicate them, this connectdata struct won't change */ ftp->user = conn->user; @@ -3076,14 +3076,14 @@ static CURLcode Curl_ftp_connect(struct connectdata *conn, * Curl_proxyCONNECT we have to set back the member to the original struct * FTP pointer */ - ftp_save = data->reqdata.proto.ftp; + ftp_save = data->state.proto.ftp; memset(&http_proxy, 0, sizeof(http_proxy)); - data->reqdata.proto.http = &http_proxy; + data->state.proto.http = &http_proxy; result = Curl_proxyCONNECT(conn, FIRSTSOCKET, conn->host.name, conn->remote_port); - data->reqdata.proto.ftp = ftp_save; + data->state.proto.ftp = ftp_save; if(CURLE_OK != result) return result; @@ -3129,15 +3129,14 @@ static CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature) { struct SessionHandle *data = conn->data; - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; ssize_t nread; int ftpcode; CURLcode result=CURLE_OK; bool was_ctl_valid = ftpc->ctl_valid; char *path; - char *path_to_use = data->reqdata.path; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + char *path_to_use = data->state.path; if(!ftp) /* When the easy handle is removed from the multi while libcurl is still @@ -3281,22 +3280,24 @@ static CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, } } else { - if((-1 != k->size) && (k->size != *ftp->bytecountp) && + if((-1 != data->req.size) && + (data->req.size != *ftp->bytecountp) && #ifdef CURL_DO_LINEEND_CONV /* Most FTP servers don't adjust their file SIZE response for CRLFs, so * we'll check to see if the discrepancy can be explained by the number * of CRLFs we've changed to LFs. */ - ((k->size + data->state.crlf_conversions) != *ftp->bytecountp) && + ((data->req.size + data->state.crlf_conversions) != + *ftp->bytecountp) && #endif /* CURL_DO_LINEEND_CONV */ - (k->maxdownload != *ftp->bytecountp)) { + (data->req.maxdownload != *ftp->bytecountp)) { failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes", *ftp->bytecountp); result = CURLE_PARTIAL_FILE; } else if(!ftpc->dont_check && !*ftp->bytecountp && - (k->size>0)) { + (data->req.size>0)) { failf(data, "No data was received!"); result = CURLE_FTP_COULDNT_RETR_FILE; } @@ -3426,8 +3427,8 @@ static CURLcode ftp_range(struct connectdata *conn) struct SessionHandle *data = conn->data; struct ftp_conn *ftpc = &conn->proto.ftpc; - if(data->reqdata.use_range && data->reqdata.range) { - from=curlx_strtoofft(data->reqdata.range, &ptr, 0); + if(data->state.use_range && data->state.range) { + from=curlx_strtoofft(data->state.range, &ptr, 0); while(ptr && *ptr && (ISSPACE(*ptr) || (*ptr=='-'))) ptr++; to=curlx_strtoofft(ptr, &ptr2, 0); @@ -3437,34 +3438,34 @@ static CURLcode ftp_range(struct connectdata *conn) } if((-1 == to) && (from>=0)) { /* X - */ - data->reqdata.resume_from = from; + data->state.resume_from = from; DEBUGF(infof(conn->data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n", from)); } else if(from < 0) { /* -Y */ totalsize = -from; - data->reqdata.maxdownload = -from; - data->reqdata.resume_from = from; + data->req.maxdownload = -from; + data->state.resume_from = from; DEBUGF(infof(conn->data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n", totalsize)); } else { /* X-Y */ totalsize = to-from; - data->reqdata.maxdownload = totalsize+1; /* include last byte */ - data->reqdata.resume_from = from; + data->req.maxdownload = totalsize+1; /* include last byte */ + data->state.resume_from = from; DEBUGF(infof(conn->data, "FTP RANGE from %" FORMAT_OFF_T " getting %" FORMAT_OFF_T " bytes\n", - from, data->reqdata.maxdownload)); + from, data->req.maxdownload)); } DEBUGF(infof(conn->data, "range-download from %" FORMAT_OFF_T " to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n", - from, to, data->reqdata.maxdownload)); + from, to, data->req.maxdownload)); ftpc->dont_check = TRUE; /* dont check for successful transfer */ } else - data->reqdata.maxdownload = -1; + data->req.maxdownload = -1; return CURLE_OK; } @@ -3483,7 +3484,7 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn) CURLcode result = CURLE_OK; /* the ftp struct is inited in Curl_ftp_connect() */ - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; DEBUGF(infof(data, "DO-MORE phase starts\n")); @@ -3558,7 +3559,7 @@ CURLcode ftp_perform(struct connectdata *conn, if(conn->bits.no_body) { /* requested no body means no transfer... */ - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; ftp->transfer = FTPTRANSFER_INFO; } @@ -3840,11 +3841,11 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) { struct SessionHandle *data = conn->data; /* the ftp struct is already inited in ftp_connect() */ - struct FTP *ftp = data->reqdata.proto.ftp; + struct FTP *ftp = data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; size_t dlen; char *slash_pos; /* position of the first '/' char in curpos */ - char *path_to_use = data->reqdata.path; + char *path_to_use = data->state.path; char *cur_pos; cur_pos = path_to_use; /* current position in path. point at the begin @@ -3864,10 +3865,10 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) the first condition in the if() right here, is there just in case someone decides to set path to NULL one day */ - if(data->reqdata.path && - data->reqdata.path[0] && - (data->reqdata.path[strlen(data->reqdata.path) - 1] != '/') ) - ftpc->file = data->reqdata.path; /* this is a full file path */ + if(data->state.path && + data->state.path[0] && + (data->state.path[strlen(data->state.path) - 1] != '/') ) + ftpc->file = data->state.path; /* this is a full file path */ else ftpc->file = NULL; /* @@ -3924,7 +3925,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) /* parse the URL path into separate path components */ while((slash_pos = strchr(cur_pos, '/')) != NULL) { /* 1 or 0 to indicate absolute directory */ - bool absolute_dir = (bool)((cur_pos - data->reqdata.path > 0) && + bool absolute_dir = (bool)((cur_pos - data->state.path > 0) && (ftpc->dirdepth == 0)); /* seek out the next path component */ @@ -3995,7 +3996,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) if(ftpc->prevpath) { /* prevpath is "raw" so we convert the input path before we compare the strings */ - char *path = curl_easy_unescape(conn->data, data->reqdata.path, 0, NULL); + char *path = curl_easy_unescape(conn->data, data->state.path, 0, NULL); if(!path) { freedirs(ftpc); return CURLE_OUT_OF_MEMORY; @@ -4018,7 +4019,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn, bool connected) { CURLcode result = CURLE_OK; - struct FTP *ftp = conn->data->reqdata.proto.ftp; + struct FTP *ftp = conn->data->state.proto.ftp; struct ftp_conn *ftpc = &conn->proto.ftpc; if(connected) @@ -4078,7 +4079,7 @@ CURLcode ftp_regular_transfer(struct connectdata *conn, bool connected=0; struct SessionHandle *data = conn->data; struct ftp_conn *ftpc = &conn->proto.ftpc; - data->reqdata.size = -1; /* make sure this is unknown at this point */ + data->req.size = -1; /* make sure this is unknown at this point */ Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); @@ -4134,11 +4135,11 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn) #endif } - data->reqdata.path++; /* don't include the initial slash */ + data->state.path++; /* don't include the initial slash */ /* FTP URLs support an extension like ";type=<typecode>" that * we'll try to get now! */ - type = strstr(data->reqdata.path, ";type="); + type = strstr(data->state.path, ";type="); if(!type) type = strstr(conn->host.rawalloc, ";type="); diff --git a/lib/http.c b/lib/http.c index 5fceb8f82..635506e08 100644 --- a/lib/http.c +++ b/lib/http.c @@ -275,8 +275,7 @@ static bool pickoneauth(struct auth *pick) static CURLcode perhapsrewind(struct connectdata *conn) { struct SessionHandle *data = conn->data; - struct HTTP *http = data->reqdata.proto.http; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct HTTP *http = data->state.proto.http; curl_off_t bytessent; curl_off_t expectsend = -1; /* default is unknown */ @@ -338,7 +337,7 @@ static CURLcode perhapsrewind(struct connectdata *conn) /* This is not NTLM or NTLM with many bytes left to send: close */ conn->bits.close = TRUE; - k->size = 0; /* don't download any more than 0 bytes */ + data->req.size = 0; /* don't download any more than 0 bytes */ } if(bytessent) @@ -361,7 +360,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) bool pickproxy = FALSE; CURLcode code = CURLE_OK; - if(100 == data->reqdata.keep.httpcode) + if(100 == data->req.httpcode) /* this is a transient response code, ignore */ return CURLE_OK; @@ -369,23 +368,23 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK; if(conn->bits.user_passwd && - ((data->reqdata.keep.httpcode == 401) || - (conn->bits.authneg && data->reqdata.keep.httpcode < 300))) { + ((data->req.httpcode == 401) || + (conn->bits.authneg && data->req.httpcode < 300))) { pickhost = pickoneauth(&data->state.authhost); if(!pickhost) data->state.authproblem = TRUE; } if(conn->bits.proxy_user_passwd && - ((data->reqdata.keep.httpcode == 407) || - (conn->bits.authneg && data->reqdata.keep.httpcode < 300))) { + ((data->req.httpcode == 407) || + (conn->bits.authneg && data->req.httpcode < 300))) { pickproxy = pickoneauth(&data->state.authproxy); if(!pickproxy) data->state.authproblem = TRUE; } if(pickhost || pickproxy) { - data->reqdata.newurl = strdup(data->change.url); /* clone URL */ - if(!data->reqdata.newurl) + data->req.newurl = strdup(data->change.url); /* clone URL */ + if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; if((data->set.httpreq != HTTPREQ_GET) && @@ -397,7 +396,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) } } - else if((data->reqdata.keep.httpcode < 300) && + else if((data->req.httpcode < 300) && (!data->state.authhost.done) && conn->bits.authneg) { /* no (known) authentication available, @@ -406,15 +405,15 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) we didn't try HEAD or GET */ if((data->set.httpreq != HTTPREQ_GET) && (data->set.httpreq != HTTPREQ_HEAD)) { - data->reqdata.newurl = strdup(data->change.url); /* clone URL */ - if(!data->reqdata.newurl) + data->req.newurl = strdup(data->change.url); /* clone URL */ + if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authhost.done = TRUE; } } if(Curl_http_should_fail(conn)) { failf (data, "The requested URL returned error: %d", - data->reqdata.keep.httpcode); + data->req.httpcode); code = CURLE_HTTP_RETURNED_ERROR; } @@ -660,8 +659,8 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, /* if exactly this is wanted, go */ int neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start); if(neg == 0) { - data->reqdata.newurl = strdup(data->change.url); - data->state.authproblem = (data->reqdata.newurl == NULL); + data->req.newurl = strdup(data->change.url); + data->state.authproblem = (data->req.newurl == NULL); } else { infof(data, "Authentication problem. Ignoring this.\n"); @@ -743,16 +742,13 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, int Curl_http_should_fail(struct connectdata *conn) { struct SessionHandle *data; - struct Curl_transfer_keeper *k; + int httpcode; DEBUGASSERT(conn); data = conn->data; DEBUGASSERT(data); - /* - ** For readability - */ - k = &data->reqdata.keep; + httpcode = data->req.httpcode; /* ** If we haven't been asked to fail on error, @@ -764,12 +760,12 @@ int Curl_http_should_fail(struct connectdata *conn) /* ** Any code < 400 is never terminal. */ - if(k->httpcode < 400) + if(httpcode < 400) return 0; - if(data->reqdata.resume_from && - (data->set.httpreq==HTTPREQ_GET) && - (k->httpcode == 416)) { + if(data->state.resume_from && + (data->set.httpreq==HTTPREQ_GET) && + (httpcode == 416)) { /* "Requested Range Not Satisfiable", just proceed and pretend this is no error */ return 0; @@ -779,14 +775,14 @@ int Curl_http_should_fail(struct connectdata *conn) ** Any code >= 400 that's not 401 or 407 is always ** a terminal error */ - if((k->httpcode != 401) && - (k->httpcode != 407)) + if((httpcode != 401) && + (httpcode != 407)) return 1; /* ** All we have left to deal with is 401 and 407 */ - DEBUGASSERT((k->httpcode == 401) || (k->httpcode == 407)); + DEBUGASSERT((httpcode == 401) || (httpcode == 407)); /* ** Examine the current authentication state to see if this @@ -807,7 +803,8 @@ int Curl_http_should_fail(struct connectdata *conn) infof(data,"%s: authavail = 0x%08x\n",__FUNCTION__,data->state.authavail); infof(data,"%s: httpcode = %d\n",__FUNCTION__,k->httpcode); infof(data,"%s: authdone = %d\n",__FUNCTION__,data->state.authdone); - infof(data,"%s: newurl = %s\n",__FUNCTION__,data->reqdata.newurl ? data->reqdata.newurl : "(null)"); + infof(data,"%s: newurl = %s\n",__FUNCTION__,data->req.newurl ? + data->req.newurl : "(null)"); infof(data,"%s: authproblem = %d\n",__FUNCTION__,data->state.authproblem); #endif @@ -815,9 +812,9 @@ int Curl_http_should_fail(struct connectdata *conn) ** Either we're not authenticating, or we're supposed to ** be authenticating something else. This is an error. */ - if((k->httpcode == 401) && !conn->bits.user_passwd) + if((httpcode == 401) && !conn->bits.user_passwd) return TRUE; - if((k->httpcode == 407) && !conn->bits.proxy_user_passwd) + if((httpcode == 407) && !conn->bits.proxy_user_passwd) return TRUE; return data->state.authproblem; @@ -837,7 +834,7 @@ static size_t readmoredata(char *buffer, void *userp) { struct connectdata *conn = (struct connectdata *)userp; - struct HTTP *http = conn->data->reqdata.proto.http; + struct HTTP *http = conn->data->state.proto.http; size_t fullsize = size * nitems; if(0 == http->postsize) @@ -929,7 +926,7 @@ CURLcode add_buffer_send(send_buffer *in, CURLcode res; char *ptr; size_t size; - struct HTTP *http = conn->data->reqdata.proto.http; + struct HTTP *http = conn->data->state.proto.http; size_t sendsize; curl_socket_t sockfd; size_t headersize; @@ -1220,7 +1217,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, { int subversion=0; struct SessionHandle *data=conn->data; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; CURLcode result; int res; long timeout = @@ -1246,12 +1243,12 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, infof(data, "Establish HTTP proxy tunnel to %s:%d\n", hostname, remote_port); - if(data->reqdata.newurl) { + if(data->req.newurl) { /* This only happens if we've looped here due to authentication reasons, and we don't really use the newly cloned URL here then. Just free() it. */ - free(data->reqdata.newurl); - data->reqdata.newurl = NULL; + free(data->req.newurl); + data->req.newurl = NULL; } /* initialize a dynamic send-buffer */ @@ -1603,20 +1600,20 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, headers. 'newurl' is set to a new URL if we must loop. */ Curl_http_auth_act(conn); - if(closeConnection && data->reqdata.newurl) { + if(closeConnection && data->req.newurl) { /* Connection closed by server. Don't use it anymore */ sclose(conn->sock[sockindex]); conn->sock[sockindex] = CURL_SOCKET_BAD; break; } } /* END NEGOTIATION PHASE */ - } while(data->reqdata.newurl); + } while(data->req.newurl); - if(200 != k->httpcode) { + if(200 != data->req.httpcode) { failf(data, "Received HTTP code %d from proxy after CONNECT", - k->httpcode); + data->req.httpcode); - if(closeConnection && data->reqdata.newurl) + if(closeConnection && data->req.newurl) conn->bits.proxy_connect_closed = TRUE; return CURLE_RECV_ERROR; @@ -1631,7 +1628,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, data->state.authproxy.done = TRUE; infof (data, "Proxy replied OK to CONNECT request\n"); - k->ignorebody = FALSE; /* put it (back) to non-ignore state */ + data->req.ignorebody = FALSE; /* put it (back) to non-ignore state */ return CURLE_OK; } @@ -1790,8 +1787,7 @@ CURLcode Curl_http_done(struct connectdata *conn, CURLcode status, bool premature) { struct SessionHandle *data = conn->data; - struct HTTP *http =data->reqdata.proto.http; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct HTTP *http =data->state.proto.http; (void)premature; /* not used */ /* set the proper values (possibly modified on POST) */ @@ -1810,7 +1806,7 @@ CURLcode Curl_http_done(struct connectdata *conn, } if(HTTPREQ_POST_FORM == data->set.httpreq) { - k->bytecount = http->readbytecount + http->writebytecount; + data->req.bytecount = http->readbytecount + http->writebytecount; Curl_formclean(&http->sendit); /* Now free that whole lot */ if(http->form.fp) { @@ -1820,15 +1816,15 @@ CURLcode Curl_http_done(struct connectdata *conn, } } else if(HTTPREQ_PUT == data->set.httpreq) - k->bytecount = http->readbytecount + http->writebytecount; + data->req.bytecount = http->readbytecount + http->writebytecount; if(status != CURLE_OK) return (status); if(!conn->bits.retry && ((http->readbytecount + - data->reqdata.keep.headerbytecount - - data->reqdata.keep.deductheadercount)) <= 0) { + data->req.headerbytecount - + data->req.deductheadercount)) <= 0) { /* If this connection isn't simply closed to be retried, AND nothing was read from the HTTP server (that counts), this can't be right so we return an error here */ @@ -1911,7 +1907,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) char *buf = data->state.buffer; /* this is a short cut to the buffer */ CURLcode result=CURLE_OK; struct HTTP *http; - char *ppath = data->reqdata.path; + char *ppath = data->state.path; char ftp_typecode[sizeof(";type=?")] = ""; char *host = conn->host.name; const char *te = ""; /* transfer-encoding */ @@ -1930,16 +1926,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) sessionhandle, deal with it */ Curl_reset_reqproto(conn); - if(!data->reqdata.proto.http) { + if(!data->state.proto.http) { /* Only allocate this struct if we don't already have it! */ http = (struct HTTP *)calloc(sizeof(struct HTTP), 1); if(!http) return CURLE_OUT_OF_MEMORY; - data->reqdata.proto.http = http; + data->state.proto.http = http; } else - http = data->reqdata.proto.http; + http = data->state.proto.http; if( (conn->protocol&(PROT_HTTP|PROT_FTP)) && data->set.upload) { @@ -2169,7 +2165,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(( (HTTPREQ_POST == httpreq) || (HTTPREQ_POST_FORM == httpreq) || (HTTPREQ_PUT == httpreq) ) && - data->reqdata.resume_from) { + data->state.resume_from) { /********************************************************************** * Resuming upload in HTTP means that we PUT or POST and that we have * got a resume_from value set. The resume value has already created @@ -2178,15 +2174,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) * file size before we continue this venture in the dark lands of HTTP. *********************************************************************/ - if(data->reqdata.resume_from < 0 ) { + if(data->state.resume_from < 0 ) { /* * This is meant to get the size of the present remote-file by itself. * We don't support this now. Bail out! */ - data->reqdata.resume_from = 0; + data->state.resume_from = 0; } - if(data->reqdata.resume_from && !data->state.this_is_a_follow) { + if(data->state.resume_from && !data->state.this_is_a_follow) { /* do we still game? */ curl_off_t passed=0; @@ -2194,7 +2190,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) input. If we knew it was a proper file we could've just fseek()ed but we only have a stream here */ do { - size_t readthisamountnow = (size_t)(data->reqdata.resume_from - passed); + size_t readthisamountnow = (size_t)(data->state.resume_from - passed); size_t actuallyread; if(readthisamountnow > BUFSIZE) @@ -2211,11 +2207,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) passed); return CURLE_READ_ERROR; } - } while(passed != data->reqdata.resume_from); /* loop until done */ + } while(passed != data->state.resume_from); /* loop until done */ /* now, decrease the size of the read */ if(data->set.infilesize>0) { - data->set.infilesize -= data->reqdata.resume_from; + data->set.infilesize -= data->state.resume_from; if(data->set.infilesize <= 0) { failf(data, "File already completely uploaded"); @@ -2225,7 +2221,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) /* we've passed, proceed as normal */ } } - if(data->reqdata.use_range) { + if(data->state.use_range) { /* * A range is selected. We use different headers whether we're downloading * or uploading and we always let customized headers override our internal @@ -2237,7 +2233,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(conn->allocptr.rangeline) free(conn->allocptr.rangeline); conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", - data->reqdata.range); + data->state.range); } else if((httpreq != HTTPREQ_GET) && !checkheaders(data, "Content-Range:")) { @@ -2246,14 +2242,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(conn->allocptr.rangeline) free(conn->allocptr.rangeline); - if(data->reqdata.resume_from) { + if(data->state.resume_from) { /* This is because "resume" was selected */ curl_off_t total_expected_size= - data->reqdata.resume_from + data->set.infilesize; + data->state.resume_from + data->set.infilesize; conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%" FORMAT_OFF_T "/%" FORMAT_OFF_T "\r\n", - data->reqdata.range, total_expected_size-1, + data->state.range, total_expected_size-1, total_expected_size); } else { @@ -2261,7 +2257,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) append total size */ conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%" FORMAT_OFF_T "\r\n", - data->reqdata.range, data->set.infilesize); + data->state.range, data->set.infilesize); } if(!conn->allocptr.rangeline) return CURLE_OUT_OF_MEMORY; @@ -2306,7 +2302,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) conn->allocptr.proxyuserpwd? conn->allocptr.proxyuserpwd:"", conn->allocptr.userpwd?conn->allocptr.userpwd:"", - (data->reqdata.use_range && conn->allocptr.rangeline)? + (data->state.use_range && conn->allocptr.rangeline)? conn->allocptr.rangeline:"", (data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT] && conn->allocptr.uagent)? @@ -2340,7 +2336,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) co = Curl_cookie_getlist(data->cookies, conn->allocptr.cookiehost? conn->allocptr.cookiehost:host, - data->reqdata.path, + data->state.path, (bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE)); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 305a8a97a..2bf161560 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -109,7 +109,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, CURLcode result=CURLE_OK; struct SessionHandle *data = conn->data; struct Curl_chunker *ch = &conn->chunk; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; size_t piece; size_t length = (size_t)datalen; size_t *wrote = (size_t *)wrotep; @@ -217,7 +217,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, /* Write the data portion available */ #ifdef HAVE_LIBZ switch (conn->data->set.http_ce_skip? - IDENTITY : data->reqdata.keep.content_encoding) { + IDENTITY : data->req.content_encoding) { case IDENTITY: #endif if(!k->ignorebody) { @@ -231,16 +231,16 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, break; case DEFLATE: - /* update data->reqdata.keep.str to point to the chunk data. */ - data->reqdata.keep.str = datap; - result = Curl_unencode_deflate_write(conn, &data->reqdata.keep, + /* update data->req.keep.str to point to the chunk data. */ + data->req.str = datap; + result = Curl_unencode_deflate_write(conn, &data->req, (ssize_t)piece); break; case GZIP: - /* update data->reqdata.keep.str to point to the chunk data. */ - data->reqdata.keep.str = datap; - result = Curl_unencode_gzip_write(conn, &data->reqdata.keep, + /* update data->req.keep.str to point to the chunk data. */ + data->req.str = datap; + result = Curl_unencode_gzip_write(conn, &data->req, (ssize_t)piece); break; diff --git a/lib/multi.c b/lib/multi.c index 061e7b5e4..042694ca5 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -845,7 +845,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, bool dophase_done; bool done; CURLMcode result = CURLM_OK; - struct Curl_transfer_keeper *k; + struct SingleRequest *k; do { bool disconnect_conn = FALSE; @@ -857,7 +857,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, we're using gets cleaned up and we're left with nothing. */ if(easy->easy_handle->state.pipe_broke) { infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n", - easy, easy->easy_handle->reqdata.path); + easy, easy->easy_handle->state.path); if(easy->easy_handle->state.is_in_pipeline) { /* Head back to the CONNECT state */ @@ -1252,7 +1252,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* read/write data if it is ready to do so */ easy->result = Curl_readwrite(easy->easy_conn, &done); - k = &easy->easy_handle->reqdata.keep; + k = &easy->easy_handle->req; if(!(k->keepon & KEEP_READ)) { /* We're done reading */ @@ -1289,14 +1289,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, Curl_posttransfer(easy->easy_handle); /* When we follow redirects, must to go back to the CONNECT state */ - if(easy->easy_handle->reqdata.newurl || retry) { + if(easy->easy_handle->req.newurl || retry) { Curl_removeHandleFromPipeline(easy->easy_handle, easy->easy_conn->recv_pipe); if(!retry) { /* if the URL is a follow-location and not just a retried request then figure out the URL here */ - newurl = easy->easy_handle->reqdata.newurl; - easy->easy_handle->reqdata.newurl = NULL; + newurl = easy->easy_handle->req.newurl; + easy->easy_handle->req.newurl = NULL; } easy->result = Curl_done(&easy->easy_conn, CURLE_OK, FALSE); if(easy->result == CURLE_OK) diff --git a/lib/progress.c b/lib/progress.c index ad09938f8..f473e8227 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -356,11 +356,10 @@ int Curl_pgrsUpdate(struct connectdata *conn) progress */ if(!(data->progress.flags & PGRS_HEADERS_OUT)) { - if(data->reqdata.resume_from) { + if(data->state.resume_from) { fprintf(data->set.err, - "** Resuming transfer from byte position %" FORMAT_OFF_T - "\n", - data->reqdata.resume_from); + "** Resuming transfer from byte position %" FORMAT_OFF_T "\n", + data->state.resume_from); } fprintf(data->set.err, " %% Total %% Received %% Xferd Average Speed Time Time Time Current\n" @@ -374,7 +374,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, char *working_path; int working_path_len; - working_path = curl_easy_unescape(data, data->reqdata.path, 0, + working_path = curl_easy_unescape(data, data->state.path, 0, &working_path_len); if(!working_path) return CURLE_OUT_OF_MEMORY; @@ -432,7 +432,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct SSHPROTO *sftp_scp = data->reqdata.proto.ssh; + struct SSHPROTO *sftp_scp = data->state.proto.ssh; struct ssh_conn *sshc = &conn->proto.sshc; curl_socket_t sock = conn->sock[FIRSTSOCKET]; #ifdef CURL_LIBSSH2_DEBUG @@ -1350,7 +1350,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) } /* since this counts what we send to the client, we include the newline in this counter */ - data->reqdata.keep.bytecount += sshc->readdir_len+1; + data->req.bytecount += sshc->readdir_len+1; /* output debug output if that is requested */ if(data->set.verbose) { @@ -1469,7 +1469,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, sshc->readdir_currLen, conn); } - data->reqdata.keep.bytecount += sshc->readdir_currLen; + data->req.bytecount += sshc->readdir_currLen; } Curl_safefree(sshc->readdir_line); sshc->readdir_line = NULL; @@ -1533,18 +1533,18 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) * libssh2_sftp_open() didn't return an error, so maybe the server * just doesn't support stat() */ - data->reqdata.size = -1; - data->reqdata.maxdownload = -1; + data->req.size = -1; + data->req.maxdownload = -1; } else { - data->reqdata.size = attrs.filesize; - data->reqdata.maxdownload = attrs.filesize; + data->req.size = attrs.filesize; + data->req.maxdownload = attrs.filesize; Curl_pgrsSetDownloadSize(data, attrs.filesize); } } /* Setup the actual download */ - result = Curl_setup_transfer(conn, FIRSTSOCKET, data->reqdata.size, + result = Curl_setup_transfer(conn, FIRSTSOCKET, data->req.size, FALSE, NULL, -1, NULL); if(result) { state(conn, SSH_SFTP_CLOSE); @@ -1648,7 +1648,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) } /* upload data */ - result = Curl_setup_transfer(conn, -1, data->reqdata.size, FALSE, NULL, + result = Curl_setup_transfer(conn, -1, data->req.size, FALSE, NULL, FIRSTSOCKET, NULL); if(result) { @@ -1696,7 +1696,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) /* download data */ bytecount = (curl_off_t)sb.st_size; - data->reqdata.maxdownload = (curl_off_t)sb.st_size; + data->req.maxdownload = (curl_off_t)sb.st_size; result = Curl_setup_transfer(conn, FIRSTSOCKET, bytecount, FALSE, NULL, -1, NULL); @@ -1849,14 +1849,14 @@ static CURLcode ssh_init(struct connectdata *conn) { struct SessionHandle *data = conn->data; struct SSHPROTO *ssh; - if(data->reqdata.proto.ssh) + if(data->state.proto.ssh) return CURLE_OK; ssh = (struct SSHPROTO *)calloc(sizeof(struct SSHPROTO), 1); if(!ssh) return CURLE_OUT_OF_MEMORY; - data->reqdata.proto.ssh = ssh; + data->state.proto.ssh = ssh; return CURLE_OK; } @@ -1989,7 +1989,7 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done) *done = FALSE; /* default to false */ - data->reqdata.size = -1; /* make sure this is unknown at this point */ + data->req.size = -1; /* make sure this is unknown at this point */ Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); @@ -2011,8 +2011,8 @@ static CURLcode scp_disconnect(struct connectdata *conn) { CURLcode result; - Curl_safefree(conn->data->reqdata.proto.ssh); - conn->data->reqdata.proto.ssh = NULL; + Curl_safefree(conn->data->state.proto.ssh); + conn->data->state.proto.ssh = NULL; state(conn, SSH_SESSION_DISCONNECT); @@ -2046,7 +2046,7 @@ static CURLcode scp_done(struct connectdata *conn, CURLcode status, } if(done) { - struct SSHPROTO *sftp_scp = conn->data->reqdata.proto.ssh; + struct SSHPROTO *sftp_scp = conn->data->state.proto.ssh; Curl_safefree(sftp_scp->path); sftp_scp->path = NULL; Curl_pgrsDone(conn); @@ -2154,8 +2154,8 @@ static CURLcode sftp_disconnect(struct connectdata *conn) DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n")); - Curl_safefree(conn->data->reqdata.proto.ssh); - conn->data->reqdata.proto.ssh = NULL; + Curl_safefree(conn->data->state.proto.ssh); + conn->data->state.proto.ssh = NULL; state(conn, SSH_SFTP_SHUTDOWN); result = ssh_easy_statemach(conn); diff --git a/lib/telnet.c b/lib/telnet.c index 90f49dc51..86450bbbe 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -245,7 +245,7 @@ CURLcode init_telnet(struct connectdata *conn) if(!tn) return CURLE_OUT_OF_MEMORY; - conn->data->reqdata.proto.telnet = (void *)tn; /* make us known */ + conn->data->state.proto.telnet = (void *)tn; /* make us known */ tn->telrcv_state = CURL_TS_DATA; @@ -264,7 +264,7 @@ CURLcode init_telnet(struct connectdata *conn) static void negotiate(struct connectdata *conn) { int i; - struct TELNET *tn = (struct TELNET *) conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *) conn->data->state.proto.telnet; for(i = 0;i < CURL_NTELOPTS;i++) { @@ -340,7 +340,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option) static void set_remote_option(struct connectdata *conn, int option, int newstate) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; if(newstate == CURL_YES) { switch(tn->him[option]) @@ -422,7 +422,7 @@ void set_remote_option(struct connectdata *conn, int option, int newstate) static void rec_will(struct connectdata *conn, int option) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; switch(tn->him[option]) { case CURL_NO: @@ -475,7 +475,7 @@ void rec_will(struct connectdata *conn, int option) static void rec_wont(struct connectdata *conn, int option) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; switch(tn->him[option]) { case CURL_NO: @@ -520,7 +520,7 @@ void rec_wont(struct connectdata *conn, int option) static void set_local_option(struct connectdata *conn, int option, int newstate) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; if(newstate == CURL_YES) { switch(tn->us[option]) @@ -602,7 +602,7 @@ set_local_option(struct connectdata *conn, int option, int newstate) static void rec_do(struct connectdata *conn, int option) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; switch(tn->us[option]) { case CURL_NO: @@ -655,7 +655,7 @@ void rec_do(struct connectdata *conn, int option) static void rec_dont(struct connectdata *conn, int option) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; switch(tn->us[option]) { case CURL_NO: @@ -817,7 +817,7 @@ static CURLcode check_telnet_options(struct connectdata *conn) char option_arg[256]; char *buf; struct SessionHandle *data = conn->data; - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; /* Add the user name as an environment variable if it was given on the command line */ @@ -888,7 +888,7 @@ static void suboption(struct connectdata *conn) char varname[128]; char varval[128]; struct SessionHandle *data = conn->data; - struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)data->state.proto.telnet; printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2); switch (CURL_SB_GET(tn)) { @@ -956,7 +956,7 @@ void telrcv(struct connectdata *conn, int in = 0; int startwrite=-1; struct SessionHandle *data = conn->data; - struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)data->state.proto.telnet; #define startskipping() \ if(startwrite >= 0) \ @@ -1120,14 +1120,14 @@ void telrcv(struct connectdata *conn, static CURLcode Curl_telnet_done(struct connectdata *conn, CURLcode status, bool premature) { - struct TELNET *tn = (struct TELNET *)conn->data->reqdata.proto.telnet; + struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet; (void)status; /* unused */ (void)premature; /* not used */ curl_slist_free_all(tn->telnet_vars); - free(conn->data->reqdata.proto.telnet); - conn->data->reqdata.proto.telnet = NULL; + free(conn->data->state.proto.telnet); + conn->data->state.proto.telnet = NULL; return CURLE_OK; } @@ -1166,7 +1166,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done) if(code) return code; - tn = (struct TELNET *)data->reqdata.proto.telnet; + tn = (struct TELNET *)data->state.proto.telnet; code = check_telnet_options(conn); if(code) diff --git a/lib/tftp.c b/lib/tftp.c index d315aadde..245334ae7 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -306,7 +306,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) if(data->set.upload) { /* If we are uploading, send an WRQ */ setpacketevent(&state->spacket, TFTP_EVENT_WRQ); - state->conn->data->reqdata.upload_fromhere = + state->conn->data->req.upload_fromhere = (char *)&state->spacket.data[4]; if(data->set.infilesize != -1) Curl_pgrsSetUploadSize(data, data->set.infilesize); @@ -317,7 +317,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) } /* As RFC3617 describes the separator slash is not actually part of the file name so we skip the always-present first letter of the path string. */ - filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0, + filename = curl_easy_unescape(data, &state->conn->data->state.path[1], 0, NULL); if(!filename) return CURLE_OUT_OF_MEMORY; @@ -460,7 +460,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) int sbytes; int rblock; CURLcode res = CURLE_OK; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; switch(event) { @@ -613,9 +613,9 @@ static CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done) sessionhandle, deal with it */ Curl_reset_reqproto(conn); - if(!(state = conn->data->reqdata.proto.tftp)) { - state = conn->data->reqdata.proto.tftp = calloc(sizeof(tftp_state_data_t), - 1); + if(!(state = conn->data->state.proto.tftp)) { + state = conn->data->state.proto.tftp = calloc(sizeof(tftp_state_data_t), + 1); if(!state) return CURLE_OUT_OF_MEMORY; } @@ -706,7 +706,7 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done) struct Curl_sockaddr_storage fromaddr; socklen_t fromlen; int check_time = 0; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; *done = TRUE; @@ -718,12 +718,12 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done) */ Curl_reset_reqproto(conn); - if(!data->reqdata.proto.tftp) { + if(!data->state.proto.tftp) { code = Curl_tftp_connect(conn, done); if(code) return code; } - state = (tftp_state_data_t *)data->reqdata.proto.tftp; + state = (tftp_state_data_t *)data->state.proto.tftp; /* Run the TFTP State Machine */ for(code=tftp_state_machine(state, TFTP_EVENT_INIT); @@ -878,7 +878,7 @@ static CURLcode Curl_tftp_setup_connection(struct connectdata * conn) /* TFTP URLs support an extension like ";mode=<typecode>" that * we'll try to get now! */ - type = strstr(data->reqdata.path, ";mode="); + type = strstr(data->state.path, ";mode="); if(!type) type = strstr(conn->host.rawalloc, ";mode="); diff --git a/lib/transfer.c b/lib/transfer.c index 01a5ee33b..2f9dd95e8 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -122,12 +122,12 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) if(conn->bits.upload_chunky) { /* if chunked Transfer-Encoding */ buffersize -= (8 + 2 + 2); /* 32bit hex + CRLF + CRLF */ - data->reqdata.upload_fromhere += 10; /* 32bit hex + CRLF */ + data->req.upload_fromhere += 10; /* 32bit hex + CRLF */ } /* this function returns a size_t, so we typecast to int to prevent warnings with picky compilers */ - nread = (int)conn->fread_func(data->reqdata.upload_fromhere, 1, + nread = (int)conn->fread_func(data->req.upload_fromhere, 1, buffersize, conn->fread_in); if(nread == CURL_READFUNC_ABORT) { @@ -141,18 +141,18 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) int hexlen = snprintf(hexbuffer, sizeof(hexbuffer), "%x\r\n", nread); /* move buffer pointer */ - data->reqdata.upload_fromhere -= hexlen; + data->req.upload_fromhere -= hexlen; nread += hexlen; /* copy the prefix to the buffer */ - memcpy(data->reqdata.upload_fromhere, hexbuffer, hexlen); + memcpy(data->req.upload_fromhere, hexbuffer, hexlen); /* always append CRLF to the data */ - memcpy(data->reqdata.upload_fromhere + nread, "\r\n", 2); + memcpy(data->req.upload_fromhere + nread, "\r\n", 2); if((nread - hexlen) == 0) { /* mark this as done once this chunk is transfered */ - data->reqdata.keep.upload_done = TRUE; + data->req.upload_done = TRUE; } nread+=2; /* for the added CRLF */ @@ -163,7 +163,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) #ifdef CURL_DOES_CONVERSIONS if(data->set.prefer_ascii) { CURLcode res; - res = Curl_convert_to_network(data, data->reqdata.upload_fromhere, nread); + res = Curl_convert_to_network(data, data->req.upload_fromhere, nread); /* Curl_convert_to_network calls failf if unsuccessful */ if(res != CURLE_OK) { return(res); @@ -315,7 +315,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, bool *done) { struct SessionHandle *data = conn->data; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; CURLcode result; ssize_t nread; /* number of bytes read */ int didwhat=0; @@ -628,12 +628,12 @@ CURLcode Curl_readwrite(struct connectdata *conn, return result; data->info.header_size += (long)headerlen; - data->reqdata.keep.headerbytecount += (long)headerlen; + data->req.headerbytecount += (long)headerlen; - data->reqdata.keep.deductheadercount = - (100 == k->httpcode)?data->reqdata.keep.headerbytecount:0; + data->req.deductheadercount = + (100 == k->httpcode)?data->req.headerbytecount:0; - if(data->reqdata.resume_from && + if(data->state.resume_from && (data->set.httpreq==HTTPREQ_GET) && (k->httpcode == 416)) { /* "Requested Range Not Satisfiable" */ @@ -792,7 +792,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, ((k->httpcode != 401) || !conn->bits.user_passwd) && ((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) { - if(data->reqdata.resume_from && + if(data->state.resume_from && (data->set.httpreq==HTTPREQ_GET) && (k->httpcode == 416)) { /* "Requested Range Not Satisfiable", just proceed and @@ -1042,7 +1042,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, k->offset = curlx_strtoofft(ptr, NULL, 10); - if(data->reqdata.resume_from == k->offset) + if(data->state.resume_from == k->offset) /* we asked for a resume and we got it */ k->content_range = TRUE; } @@ -1057,7 +1057,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, here, or else use real peer host name. */ conn->allocptr.cookiehost? conn->allocptr.cookiehost:conn->host.name, - data->reqdata.path); + data->state.path); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } #endif @@ -1105,9 +1105,9 @@ CURLcode Curl_readwrite(struct connectdata *conn, backup = *ptr; /* store the ending letter */ if(ptr != start) { *ptr = '\0'; /* zero terminate */ - data->reqdata.newurl = strdup(start); /* clone string */ + data->req.newurl = strdup(start); /* clone string */ *ptr = backup; /* restore ending letter */ - if(!data->reqdata.newurl) + if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; } } @@ -1131,7 +1131,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, return result; data->info.header_size += (long)k->hbuflen; - data->reqdata.keep.headerbytecount += (long)k->hbuflen; + data->req.headerbytecount += (long)k->hbuflen; /* reset hbufp pointer && hbuflen */ k->hbufp = data->state.headerbuff; @@ -1160,7 +1160,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(conn->protocol&PROT_HTTP) { /* HTTP-only checks */ - if(data->reqdata.newurl) { + if(data->req.newurl) { if(conn->bits.close) { /* Abort after the headers if "follow Location" is set and we're set to close anyway. */ @@ -1174,7 +1174,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, k->ignorebody = TRUE; infof(data, "Ignoring the response-body\n"); } - if(data->reqdata.resume_from && !k->content_range && + if(data->state.resume_from && !k->content_range && (data->set.httpreq==HTTPREQ_GET) && !k->ignorebody) { /* we wanted to resume a download, although the server doesn't @@ -1185,7 +1185,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, return CURLE_RANGE_ERROR; } - if(data->set.timecondition && !data->reqdata.range) { + if(data->set.timecondition && !data->state.range) { /* A time condition has been set AND no ranges have been requested. This seems to be what chapter 13.3.4 of RFC 2616 defines to be the correct action for a @@ -1284,7 +1284,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, " bytes on url %s (size = %" FORMAT_OFF_T ", maxdownload = %" FORMAT_OFF_T ", bytecount = %" FORMAT_OFF_T ", nread = %d)\n", - excess, conn->data->reqdata.path, + excess, data->state.path, k->size, k->maxdownload, k->bytecount, nread); read_rewind(conn, excess); } @@ -1394,9 +1394,9 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* only read more data if there's no upload data already present in the upload buffer */ - if(0 == data->reqdata.upload_present) { + if(0 == data->req.upload_present) { /* init the "upload from here" pointer */ - data->reqdata.upload_fromhere = k->uploadbuf; + data->req.upload_fromhere = k->uploadbuf; if(!k->upload_done) { /* HTTP pollution, this should be written nicer to become more @@ -1404,7 +1404,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, int fillcount; if(k->wait100_after_headers && - (data->reqdata.proto.http->sending == HTTPSEND_BODY)) { + (data->state.proto.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 */ @@ -1441,7 +1441,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } /* store number of bytes available for upload */ - data->reqdata.upload_present = nread; + data->req.upload_present = nread; /* convert LF to CRLF if so asked */ #ifdef CURL_DO_LINEEND_CONV @@ -1463,7 +1463,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, * must be used instead of the escape sequences \r & \n. */ for(i = 0, si = 0; i < nread; i++, si++) { - if(data->reqdata.upload_fromhere[i] == 0x0a) { + if(data->req.upload_fromhere[i] == 0x0a) { data->state.scratch[si++] = 0x0d; data->state.scratch[si] = 0x0a; if(!data->set.crlf) { @@ -1473,7 +1473,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } else - data->state.scratch[si] = data->reqdata.upload_fromhere[i]; + data->state.scratch[si] = data->req.upload_fromhere[i]; } if(si != nread) { /* only perform the special operation if we really did replace @@ -1481,10 +1481,10 @@ CURLcode Curl_readwrite(struct connectdata *conn, nread = si; /* upload from the new (replaced) buffer instead */ - data->reqdata.upload_fromhere = data->state.scratch; + data->req.upload_fromhere = data->state.scratch; /* set the new amount too */ - data->reqdata.upload_present = nread; + data->req.upload_present = nread; } } } @@ -1496,33 +1496,33 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* write to socket (send away data) */ result = Curl_write(conn, conn->writesockfd, /* socket to send to */ - data->reqdata.upload_fromhere, /* buffer pointer */ - data->reqdata.upload_present, /* buffer size */ + data->req.upload_fromhere, /* buffer pointer */ + data->req.upload_present, /* buffer size */ &bytes_written); /* actually send away */ if(result) return result; if(data->set.verbose) /* show the data before we change the pointer upload_fromhere */ - Curl_debug(data, CURLINFO_DATA_OUT, data->reqdata.upload_fromhere, + Curl_debug(data, CURLINFO_DATA_OUT, data->req.upload_fromhere, (size_t)bytes_written, conn); - if(data->reqdata.upload_present != bytes_written) { + if(data->req.upload_present != bytes_written) { /* we only wrote a part of the buffer (if anything), deal with it! */ /* store the amount of bytes left in the buffer to write */ - data->reqdata.upload_present -= bytes_written; + data->req.upload_present -= bytes_written; /* advance the pointer where to find the buffer when the next send is to happen */ - data->reqdata.upload_fromhere += bytes_written; + data->req.upload_fromhere += bytes_written; writedone = TRUE; /* we are done, stop the loop */ } else { /* we've uploaded that buffer now */ - data->reqdata.upload_fromhere = k->uploadbuf; - data->reqdata.upload_present = 0; /* no more bytes left */ + data->req.upload_fromhere = k->uploadbuf; + data->req.upload_present = 0; /* no more bytes left */ if(k->upload_done) { /* switch off writing, we're done! */ @@ -1609,7 +1609,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, */ (k->bytecount != (k->size + data->state.crlf_conversions)) && #endif /* CURL_DO_LINEEND_CONV */ - !data->reqdata.newurl) { + !data->req.newurl) { failf(data, "transfer closed with %" FORMAT_OFF_T " bytes remaining to read", k->size - k->bytecount); @@ -1660,7 +1660,7 @@ int Curl_single_getsock(const struct connectdata *conn, /* simple check but we might need two slots */ return GETSOCK_BLANK; - if(data->reqdata.keep.keepon & KEEP_READ) { + if(data->req.keepon & KEEP_READ) { DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); @@ -1668,13 +1668,13 @@ int Curl_single_getsock(const struct connectdata *conn, sock[sockindex] = conn->sockfd; } - if(data->reqdata.keep.keepon & KEEP_WRITE) { + if(data->req.keepon & KEEP_WRITE) { if((conn->sockfd != conn->writesockfd) || - !(data->reqdata.keep.keepon & KEEP_READ)) { + !(data->req.keepon & KEEP_READ)) { /* only if they are not the same socket or we didn't have a readable one, we increase index */ - if(data->reqdata.keep.keepon & KEEP_READ) + if(data->req.keepon & KEEP_READ) sockindex++; /* increase index if we need two entries */ DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); @@ -1708,7 +1708,7 @@ Transfer(struct connectdata *conn) { CURLcode result; struct SessionHandle *data = conn->data; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; bool done=FALSE; if((conn->sockfd == CURL_SOCKET_BAD) && @@ -2277,8 +2277,8 @@ bool Curl_retry_request(struct connectdata *conn, if(data->set.upload && !(conn->protocol&PROT_HTTP)) return retry; - if((data->reqdata.keep.bytecount + - data->reqdata.keep.headerbytecount == 0) && + if((data->req.bytecount + + data->req.headerbytecount == 0) && conn->bits.reuse && !conn->bits.no_body) { /* We got no data, we attempted to re-use a connection and yet we want a @@ -2349,7 +2349,7 @@ CURLcode Curl_perform(struct SessionHandle *data) * We must duplicate the new URL here as the connection data may * be free()ed in the Curl_done() function. */ - newurl = data->reqdata.newurl?strdup(data->reqdata.newurl):NULL; + newurl = data->req.newurl?strdup(data->req.newurl):NULL; } else { /* The transfer phase returned error, we mark the connection to get @@ -2435,12 +2435,12 @@ Curl_setup_transfer( ) { struct SessionHandle *data; - struct Curl_transfer_keeper *k; + struct SingleRequest *k; DEBUGASSERT(conn != NULL); data = conn->data; - k = &data->reqdata.keep; + k = &data->req; DEBUGASSERT((sockindex <= 1) && (sockindex >= -1)); @@ -2451,9 +2451,9 @@ Curl_setup_transfer( CURL_SOCKET_BAD:conn->sock[writesockindex]; conn->bits.getheader = getheader; - data->reqdata.size = size; - data->reqdata.bytecountp = bytecountp; - data->reqdata.writebytecountp = writecountp; + k->size = size; + k->bytecountp = bytecountp; + k->writebytecountp = writecountp; /* The code sequence below is placed in this function just because all necessary input is not always known in do_complete() as this function may @@ -2461,8 +2461,8 @@ Curl_setup_transfer( if(!conn->bits.getheader) { k->header = FALSE; - if(k->size > 0) - Curl_pgrsSetDownloadSize(data, k->size); + if(size > 0) + Curl_pgrsSetDownloadSize(data, size); } /* we want header and/or body, if neither then don't do this! */ if(conn->bits.getheader || !conn->bits.no_body) { @@ -2482,7 +2482,7 @@ Curl_setup_transfer( state info where we wait for the 100-return code */ if(data->state.expect100header && - (data->reqdata.proto.http->sending == HTTPSEND_BODY)) { + (data->state.proto.http->sending == HTTPSEND_BODY)) { /* wait with write until we either got 100-continue or a timeout */ k->write_after_100_header = TRUE; k->start100 = k->start; @@ -463,12 +463,12 @@ CURLcode Curl_close(struct SessionHandle *data) } } - if(data->reqdata.rangestringalloc) - free(data->reqdata.range); + if(data->state.rangestringalloc) + free(data->state.range); /* Free the pathbuffer */ - Curl_safefree(data->reqdata.pathbuffer); - Curl_safefree(data->reqdata.proto.generic); + Curl_safefree(data->state.pathbuffer); + Curl_safefree(data->state.proto.generic); /* Close down all open SSL info and sessions */ Curl_ssl_close_all(data); @@ -2166,7 +2166,7 @@ CURLcode Curl_disconnect(struct connectdata *conn) } conn_free(conn); - data->reqdata.current_conn = NULL; + data->state.current_conn = NULL; return CURLE_OK; } @@ -2872,7 +2872,7 @@ static CURLcode ParseURLAndFillConnection(struct SessionHandle *data, char *at; char *tmp; - char *path = data->reqdata.path; + char *path = data->state.path; /************************************************************* * Parse the URL. @@ -3030,7 +3030,7 @@ static CURLcode ParseURLAndFillConnection(struct SessionHandle *data, * So if the URL was A://B/C, * conn->protostr is A * conn->host.name is B - * data->reqdata.path is /C + * data->state.path is /C */ return CURLE_OK; @@ -3049,28 +3049,27 @@ static CURLcode setup_range(struct SessionHandle *data) * If we're doing a resumed transfer, we need to setup our stuff * properly. */ - struct HandleData *req = &data->reqdata; - - req->resume_from = data->set.set_resume_from; - if(req->resume_from || data->set.str[STRING_SET_RANGE]) { - if(req->rangestringalloc) - free(req->range); - - if(req->resume_from) - req->range = aprintf("%" FORMAT_OFF_T "-", req->resume_from); + struct UrlState *s = &data->state; + s->resume_from = data->set.set_resume_from; + if(s->resume_from || data->set.str[STRING_SET_RANGE]) { + if(s->rangestringalloc) + free(s->range); + + if(s->resume_from) + s->range = aprintf("%" FORMAT_OFF_T "-", s->resume_from); else - req->range = strdup(data->set.str[STRING_SET_RANGE]); + s->range = strdup(data->set.str[STRING_SET_RANGE]); - req->rangestringalloc = (unsigned char)(req->range?TRUE:FALSE); + s->rangestringalloc = (bool)(s->range?TRUE:FALSE); - if(!req->range) + if(!s->range) return CURLE_OUT_OF_MEMORY; /* tell ourselves to fetch this range */ - req->use_range = TRUE; /* enable range download */ + s->use_range = TRUE; /* enable range download */ } else - req->use_range = FALSE; /* disable range download */ + s->use_range = FALSE; /* disable range download */ return CURLE_OK; } @@ -3539,7 +3538,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, urllen=LEAST_PATH_ALLOC; /* Free the old buffer */ - Curl_safefree(data->reqdata.pathbuffer); + Curl_safefree(data->state.pathbuffer); /* * We malloc() the buffers below urllen+2 to make room for to possibilities: @@ -3547,10 +3546,10 @@ static CURLcode CreateConnection(struct SessionHandle *data, * 2 - an extra slash (in case a syntax like "www.host.com?moo" is used) */ - data->reqdata.pathbuffer=(char *)malloc(urllen+2); - if(NULL == data->reqdata.pathbuffer) + data->state.pathbuffer=(char *)malloc(urllen+2); + if(NULL == data->state.pathbuffer) return CURLE_OUT_OF_MEMORY; /* really bad error */ - data->reqdata.path = data->reqdata.pathbuffer; + data->state.path = data->state.pathbuffer; conn->host.rawalloc=(char *)malloc(urllen+2); if(NULL == conn->host.rawalloc) @@ -3803,7 +3802,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, char *url; url = aprintf("%s://%s:%d%s", conn->protostr, conn->host.name, - conn->remote_port, data->reqdata.path); + conn->remote_port, data->state.path); if(!url) return CURLE_OUT_OF_MEMORY; @@ -4237,7 +4236,7 @@ static CURLcode SetupConnection(struct connectdata *conn, return CURLE_OUT_OF_MEMORY; } - data->reqdata.keep.headerbytecount = 0; + data->req.headerbytecount = 0; #ifdef CURL_DO_LINEEND_CONV data->state.crlf_conversions = 0; /* reset CRLF conversion counter */ @@ -4393,9 +4392,9 @@ CURLcode Curl_done(struct connectdata **connp, conn->writechannel_inuse = FALSE; /* Cleanup possible redirect junk */ - if(data->reqdata.newurl) { - free(data->reqdata.newurl); - data->reqdata.newurl = NULL; + if(data->req.newurl) { + free(data->req.newurl); + data->req.newurl = NULL; } if(conn->dns_entry) { @@ -4458,14 +4457,13 @@ CURLcode Curl_done(struct connectdata **connp, static CURLcode do_init(struct connectdata *conn) { struct SessionHandle *data = conn->data; - struct Curl_transfer_keeper *k = &data->reqdata.keep; + struct SingleRequest *k = &data->req; conn->bits.done = FALSE; /* Curl_done() is not called yet */ conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */ - /* NB: the content encoding software depends on this initialization of - Curl_transfer_keeper.*/ - memset(k, 0, sizeof(struct Curl_transfer_keeper)); + /* NB: the content encoding software depends on this initialization */ + Curl_easy_initHandleData(data); k->start = Curl_tvnow(); /* start time */ k->now = k->start; /* current time is now */ @@ -4496,19 +4494,11 @@ static CURLcode do_init(struct connectdata *conn) */ static void do_complete(struct connectdata *conn) { - struct SessionHandle *data = conn->data; - struct Curl_transfer_keeper *k = &data->reqdata.keep; conn->bits.chunk=FALSE; conn->bits.trailerhdrpresent=FALSE; - k->maxfd = (conn->sockfd>conn->writesockfd? - conn->sockfd:conn->writesockfd)+1; - - k->size = data->reqdata.size; - k->maxdownload = data->reqdata.maxdownload; - k->bytecountp = data->reqdata.bytecountp; - k->writebytecountp = data->reqdata.writebytecountp; - + conn->data->req.maxfd = (conn->sockfd>conn->writesockfd? + conn->sockfd:conn->writesockfd)+1; } CURLcode Curl_do(struct connectdata **connp, bool *done) @@ -4602,9 +4592,9 @@ CURLcode Curl_do_more(struct connectdata *conn) void Curl_reset_reqproto(struct connectdata *conn) { struct SessionHandle *data = conn->data; - if(data->reqdata.proto.generic && data->reqdata.current_conn != conn) { - free(data->reqdata.proto.generic); - data->reqdata.proto.generic = NULL; + if(data->state.proto.generic && data->state.current_conn != conn) { + free(data->state.proto.generic); + data->state.proto.generic = NULL; } - data->reqdata.current_conn = conn; + data->state.current_conn = conn; } diff --git a/lib/urldata.h b/lib/urldata.h index beee01064..0188a8e93 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -646,16 +646,36 @@ typedef enum { } zlibInitState; #endif -/* - * This struct is all the previously local variables from Curl_perform() moved - * to struct to allow the function to return and get re-invoked better without - * losing state. - */ +#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ + defined(USE_THREADING_GETADDRINFO) +struct Curl_async { + char *hostname; + int port; + struct Curl_dns_entry *dns; + bool done; /* set TRUE when the lookup is complete */ + int status; /* if done is TRUE, this is the status from the callback */ + void *os_specific; /* 'struct thread_data' for Windows */ +}; +#endif -struct Curl_transfer_keeper { +#define FIRSTSOCKET 0 +#define SECONDARYSOCKET 1 + +/* These function pointer types are here only to allow easier typecasting + within the source when we need to cast between data pointers (such as NULL) + and function pointers. */ +typedef CURLcode (*Curl_do_more_func)(struct connectdata *); +typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool); - /** Values copied over from the HandleData struct each time on init **/ +/* + * Request specific data in the easy handle (SessionHandle). Previously, + * these members were on the connectdata struct but since a conn struct may + * now be shared between different SessionHandles, we store connection-specifc + * data here. This struct only keeps stuff that's interesting for *this* + * request, as it will be cleared between multiple ones + */ +struct SingleRequest { curl_off_t size; /* -1 if unknown at this point */ curl_off_t *bytecountp; /* return number of bytes read or NULL */ @@ -663,17 +683,15 @@ struct Curl_transfer_keeper { -1 means unlimited */ curl_off_t *writebytecountp; /* return number of bytes written or NULL */ - /** End of HandleData struct copies **/ - curl_off_t bytecount; /* total number of bytes read */ curl_off_t writebytecount; /* number of bytes written */ - long headerbytecount; /* only count received headers */ + long headerbytecount; /* only count received headers */ long deductheadercount; /* this amount of bytes doesn't count when we check - if anything has been transfered at the end of - a connection. We use this counter to make only - a 100 reply (without a following second response - code) result in a CURLE_GOT_NOTHING error code */ + if anything has been transfered at the end of a + connection. We use this counter to make only a + 100 reply (without a following second response + code) result in a CURLE_GOT_NOTHING error code */ struct timeval start; /* transfer started at this time */ struct timeval now; /* current time */ @@ -733,48 +751,10 @@ struct Curl_transfer_keeper { bool ignorebody; /* we read a response-body but we ignore it! */ bool ignorecl; /* This HTTP response has no body so we ignore the Content- Length: header */ -}; - -#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ - defined(USE_THREADING_GETADDRINFO) -struct Curl_async { - char *hostname; - int port; - struct Curl_dns_entry *dns; - bool done; /* set TRUE when the lookup is complete */ - int status; /* if done is TRUE, this is the status from the callback */ - void *os_specific; /* 'struct thread_data' for Windows */ -}; -#endif - -#define FIRSTSOCKET 0 -#define SECONDARYSOCKET 1 - -/* These function pointer types are here only to allow easier typecasting - within the source when we need to cast between data pointers (such as NULL) - and function pointers. */ -typedef CURLcode (*Curl_do_more_func)(struct connectdata *); -typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool); - - -/* - * Store's request specific data in the easy handle (SessionHandle). - * Previously, these members were on the connectdata struct but since - * a conn struct may now be shared between different SessionHandles, - * we store connection-specifc data here. - * - */ -struct HandleData { - char *pathbuffer;/* allocated buffer to store the URL's path part in */ - char *path; /* path to use, points to somewhere within the pathbuffer - area */ char *newurl; /* This can only be set if a Location: was in the document headers */ - /* This struct is inited when needed */ - struct Curl_transfer_keeper keep; - /* 'upload_present' is used to keep a byte counter of how much data there is still left in the buffer, aimed for upload. */ ssize_t upload_present; @@ -784,40 +764,6 @@ struct HandleData { and the 'upload_present' contains the number of bytes available at this position */ char *upload_fromhere; - - curl_off_t size; /* -1 if unknown at this point */ - curl_off_t *bytecountp; /* return number of bytes read or NULL */ - - curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch, -1 - means unlimited */ - curl_off_t *writebytecountp; /* return number of bytes written or NULL */ - - bool use_range; - bool rangestringalloc; /* the range string is malloc()'ed */ - - char *range; /* range, if used. See README for detailed specification on - this syntax. */ - curl_off_t resume_from; /* continue [ftp] transfer from here */ - - /* Protocol specific data. - * - ************************************************************************* - * Note that this data will be REMOVED after each request, so anything that - * should be kept/stored on a per-connection basis and thus live for the - * next requst 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 FTP *ftp; - void *tftp; /* private for tftp.c-eyes only */ - struct FILEPROTO *file; - void *telnet; /* private for telnet.c-eyes only */ - void *generic; - struct SSHPROTO *ssh; - } proto; - /* current user of this HandleData instance, or NULL */ - struct connectdata *current_conn; }; /* @@ -1246,6 +1192,36 @@ struct UrlState { bool closed; /* set to TRUE when curl_easy_cleanup() has been called on this handle, but it is kept around as mentioned for shared_conn */ + char *pathbuffer;/* allocated buffer to store the URL's path part in */ + char *path; /* path to use, points to somewhere within the pathbuffer + area */ + + bool use_range; + bool rangestringalloc; /* the range string is malloc()'ed */ + + char *range; /* range, if used. See README for detailed specification on + this syntax. */ + curl_off_t resume_from; /* continue [ftp] transfer from here */ + + /* Protocol specific data. + * + ************************************************************************* + * Note that this data will be REMOVED after each request, so anything that + * should be kept/stored on a per-connection basis and thus live for the + * next requst 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 FTP *ftp; + void *tftp; /* private for tftp.c-eyes only */ + struct FILEPROTO *file; + void *telnet; /* private for telnet.c-eyes only */ + void *generic; + struct SSHPROTO *ssh; + } proto; + /* current user of this SessionHandle instance, or NULL */ + struct connectdata *current_conn; }; @@ -1428,7 +1404,7 @@ struct UserDefined { bool ftp_create_missing_dirs; /* create directories that don't exist */ bool ftp_use_port; /* use the FTP PORT command */ bool hide_progress; /* don't use the progress meter */ - bool http_fail_on_error; /* fail on HTTP error codes >= 300 */ + bool http_fail_on_error; /* fail on HTTP error codes >= 300 */ bool http_follow_location; /* follow HTTP redirects */ bool http_disable_hostname_check_before_authentication; bool include_header; /* include received protocol headers in data output */ @@ -1496,7 +1472,7 @@ struct SessionHandle { in multi controlling structure to assist in removal. */ struct Curl_share *share; /* Share, handles global variable mutexing */ - struct HandleData reqdata; /* Request-specific data */ + struct SingleRequest req; /* Request-specific data */ struct UserDefined set; /* values set by the libcurl user */ struct DynamicStatic change; /* possibly modified userdefined data */ struct CookieInfo *cookies; /* the cookies, read from files and servers. |