您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Curl_client_write函数代码示例

51自学网 2021-06-01 20:16:00
  C++
这篇教程C++ Curl_client_write函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Curl_client_write函数的典型用法代码示例。如果您正苦于以下问题:C++ Curl_client_write函数的具体用法?C++ Curl_client_write怎么用?C++ Curl_client_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Curl_client_write函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Curl_proxyCONNECT

//.........这里部分代码省略.........                  /* we're done reading chunks! */                  infof(data, "chunk reading DONE/n");                  keepon = FALSE;                }                else                  infof(data, "Read %zd bytes of chunk, continue/n",                        tookcareof);              }            }            else              for(i = 0; i < gotbytes; ptr++, i++) {                perline++; /* amount of bytes in this line so far */                if(*ptr == 0x0a) {                  char letter;                  int writetype;                  /* convert from the network encoding */                  result = Curl_convert_from_network(data, line_start,                                                     perline);                  /* Curl_convert_from_network calls failf if unsuccessful */                  if(result)                    return result;                  /* output debug if that is requested */                  if(data->set.verbose)                    Curl_debug(data, CURLINFO_HEADER_IN,                               line_start, (size_t)perline, conn);                  /* send the header to the callback */                  writetype = CLIENTWRITE_HEADER;                  if(data->set.include_header)                    writetype |= CLIENTWRITE_BODY;                  result = Curl_client_write(conn, writetype, line_start,                                             perline);                  if(result)                    return result;                  /* Newlines are CRLF, so the CR is ignored as the line isn't                     really terminated until the LF comes. Treat a following CR                     as end-of-headers as well.*/                  if(('/r' == line_start[0]) ||                     ('/n' == line_start[0])) {                    /* end of response-headers from the proxy */                    nread = 0; /* make next read start over in the read                                  buffer */                    ptr=data->state.buffer;                    if((407 == k->httpcode) && !data->state.authproblem) {                      /* If we get a 407 response code with content length                         when we have no auth problem, we must ignore the                         whole response-body */                      keepon = 2;                      if(cl) {                        infof(data, "Ignore %" FORMAT_OFF_T                              " bytes of response-body/n", cl);                        /* remove the remaining chunk of what we already                           read */                        cl -= (gotbytes - i);                        if(cl<=0)                          /* if the whole thing was already read, we are done!                           */                          keepon=FALSE;
开发者ID:Tyf0n,项目名称:curl,代码行数:67,


示例2: Curl_pp_readresp

//.........这里部分代码省略.........      result = CURLE_RECV_ERROR;      failf(data, "response reading failed");    }    else {      /* we got a whole chunk of data, which can be anything from one       * byte to a set of lines and possible just a piece of the last       * line */      ssize_t i;      ssize_t clipamount = 0;      bool restart = FALSE;      data->req.headerbytecount += (long)gotbytes;      pp->nread_resp += gotbytes;      for(i = 0; i < gotbytes; ptr++, i++) {        perline++;        if(*ptr=='/n') {          /* a newline is CRLF in pp-talk, so the CR is ignored as             the line isn't really terminated until the LF comes */          /* output debug output if that is requested */#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)          if(!conn->sec_complete)#endif            if(data->set.verbose)              Curl_debug(data, CURLINFO_HEADER_IN,                         pp->linestart_resp, (size_t)perline, conn);          /*           * We pass all response-lines to the callback function registered           * for "headers". The response lines can be seen as a kind of           * headers.           */          result = Curl_client_write(conn, CLIENTWRITE_HEADER,                                     pp->linestart_resp, perline);          if(result)            return result;          if(pp->endofresp(pp, code)) {            /* This is the end of the last line, copy the last line to the               start of the buffer and zero terminate, for old times sake (and               krb4)! */            char *meow;            int n;            for(meow=pp->linestart_resp, n=0; meow<ptr; meow++, n++)              buf[n] = *meow;            *meow=0; /* zero terminate */            keepon=FALSE;            pp->linestart_resp = ptr+1; /* advance pointer */            i++; /* skip this before getting out */            *size = pp->nread_resp; /* size of the response */            pp->nread_resp = 0; /* restart */            break;          }          perline=0; /* line starts over here */          pp->linestart_resp = ptr+1;        }      }      if(!keepon && (i != gotbytes)) {        /* We found the end of the response lines, but we didn't parse the           full chunk of data we have read from the server. We therefore need           to store the rest of the data to be checked on the next invoke as           it may actually contain another end of response already! */        clipamount = gotbytes - i;
开发者ID:jerywang,项目名称:curl,代码行数:67,


示例3: gopher_do

static CURLcode gopher_do(struct connectdata *conn, bool *done){  CURLcode result=CURLE_OK;  struct SessionHandle *data=conn->data;  curl_socket_t sockfd = conn->sock[FIRSTSOCKET];  curl_off_t *bytecount = &data->req.bytecount;  char *path = data->state.path;  char *sel;  char *sel_org = NULL;  ssize_t amount, k;  *done = TRUE; /* unconditionally */  /* Create selector. Degenerate cases: / and /1 => convert to "" */  if(strlen(path) <= 2)    sel = (char *)"";  else {    char *newp;    size_t j, i;    int len;    /* Otherwise, drop / and the first character (i.e., item type) ... */    newp = path;    newp+=2;    /* ... then turn ? into TAB for search servers, Veronica, etc. ... */    j = strlen(newp);    for(i=0; i<j; i++)      if(newp[i] == '?')        newp[i] = '/x09';    /* ... and finally unescape */    sel = curl_easy_unescape(data, newp, 0, &len);    if(!sel)      return CURLE_OUT_OF_MEMORY;    sel_org = sel;  }  /* We use Curl_write instead of Curl_sendf to make sure the entire buffer is     sent, which could be sizeable with long selectors. */  k = curlx_uztosz(strlen(sel));  for(;;) {    result = Curl_write(conn, sockfd, sel, k, &amount);    if(!result) { /* Which may not have written it all! */      result = Curl_client_write(conn, CLIENTWRITE_HEADER, sel, amount);      if(result) {        Curl_safefree(sel_org);        return result;      }      k -= amount;      sel += amount;      if(k < 1)        break; /* but it did write it all */    }    else {      failf(data, "Failed sending Gopher request");      Curl_safefree(sel_org);      return result;    }    /* Don't busyloop. The entire loop thing is a work-around as it causes a       BLOCKING behavior which is a NO-NO. This function should rather be       split up in a do and a doing piece where the pieces that aren't       possible to send now will be sent in the doing function repeatedly       until the entire request is sent.       Wait a while for the socket to be writable. Note that this doesn't       acknowledge the timeout.    */    Curl_socket_ready(CURL_SOCKET_BAD, sockfd, 100);  }  Curl_safefree(sel_org);  /* We can use Curl_sendf to send the terminal /r/n relatively safely and     save allocing another string/doing another _write loop. */  result = Curl_sendf(sockfd, conn, "/r/n");  if(result) {    failf(data, "Failed sending Gopher request");    return result;  }  result = Curl_client_write(conn, CLIENTWRITE_HEADER, (char *)"/r/n", 2);  if(result)    return result;  Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,                      -1, NULL); /* no upload */  return CURLE_OK;}
开发者ID:BishopGIS,项目名称:cmake4libs,代码行数:90,


示例4: Curl_file

/* * Curl_file() is the protocol-specific function for the do-phase, separated * from the connect-phase above. Other protocols merely setup the transfer in * the do-phase, to have it done in the main transfer loop but since some * platforms we support don't allow select()ing etc on file handles (as * opposed to sockets) we instead perform the whole do-operation in this * function. */CURLcode Curl_file(struct connectdata *conn, bool *done){  /* This implementation ignores the host name in conformance with     RFC 1738. Only local files (reachable via the standard file system)     are supported. This means that files on remotely mounted directories     (via NFS, Samba, NT sharing) can be accessed through a file:// URL  */  CURLcode res = CURLE_OK;  struct_stat statbuf; /* struct_stat instead of struct stat just to allow the                          Windows version to have a different struct without                          having to redefine the simple word 'stat' */  curl_off_t expected_size=0;  bool fstated=FALSE;  ssize_t nread;  struct SessionHandle *data = conn->data;  char *buf = data->state.buffer;  curl_off_t bytecount = 0;  int fd;  struct timeval now = Curl_tvnow();  *done = TRUE; /* unconditionally */  Curl_readwrite_init(conn);  Curl_initinfo(data);  Curl_pgrsStartNow(data);  if(data->set.upload)    return file_upload(conn);  /* get the fd from the connection phase */  fd = conn->data->reqdata.proto.file->fd;  /* VMS: This only works reliable for STREAMLF files */  if( -1 != fstat(fd, &statbuf)) {    /* we could stat it, then read out the size */    expected_size = statbuf.st_size;    fstated = TRUE;  }  /* If we have selected NOBODY and HEADER, it means that we only want file     information. Which for FILE can't be much more than the file size and     date. */  if(conn->bits.no_body && data->set.include_header && fstated) {    CURLcode result;    snprintf(buf, sizeof(data->state.buffer),             "Content-Length: %" FORMAT_OFF_T "/r/n", expected_size);    result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);    if(result)      return result;    result = Curl_client_write(conn, CLIENTWRITE_BOTH,                               (char *)"Accept-ranges: bytes/r/n", 0);    if(result)      return result;    if(fstated) {      struct tm *tm;      time_t clock = (time_t)statbuf.st_mtime;#ifdef HAVE_GMTIME_R      struct tm buffer;      tm = (struct tm *)gmtime_r(&clock, &buffer);#else      tm = gmtime(&clock);#endif      /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */      snprintf(buf, BUFSIZE-1,               "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT/r/n",               Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],               tm->tm_mday,               Curl_month[tm->tm_mon],               tm->tm_year + 1900,               tm->tm_hour,               tm->tm_min,               tm->tm_sec);      result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);    }    return result;  }  if (data->reqdata.resume_from <= expected_size)    expected_size -= data->reqdata.resume_from;  else {    failf(data, "failed to resume file:// transfer");    return CURLE_BAD_DOWNLOAD_RESUME;  }  if (fstated && (expected_size == 0))    return CURLE_OK;  /* The following is a shortcut implementation of file reading     this is both more efficient than the former call to download() and     it avoids problems with select() and recv() on file descriptors//.........这里部分代码省略.........
开发者ID:SiteView,项目名称:ecc82Server,代码行数:101,


示例5: Curl_pop3_write

/* This function scans the body after the end-of-body and writes everything   until the end is found */CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread){  /* This code could be made into a special function in the handler struct */  CURLcode result = CURLE_OK;  struct SessionHandle *data = conn->data;  struct SingleRequest *k = &data->req;  struct pop3_conn *pop3c = &conn->proto.pop3c;  bool strip_dot = FALSE;  size_t last = 0;  size_t i;  /* Search through the buffer looking for the end-of-body marker which is     5 bytes (0d 0a 2e 0d 0a). Note that a line starting with a dot matches     the eob so the server will have prefixed it with an extra dot which we     need to strip out. Additionally the marker could of course be spread out     over 5 different data chunks */  for(i = 0; i < nread; i++) {    size_t prev = pop3c->eob;    switch(str[i]) {    case 0x0d:      if(pop3c->eob == 0) {        pop3c->eob++;        if(i) {          /* Write out the body part that didn't match */          result = Curl_client_write(conn, CLIENTWRITE_BODY, &str[last],                                     i - last);          if(result)            return result;          last = i;        }      }      else if(pop3c->eob == 3)        pop3c->eob++;      else        /* If the character match wasn't at position 0 or 3 then restart the           pattern matching */        pop3c->eob = 1;      break;    case 0x0a:      if(pop3c->eob == 1 || pop3c->eob == 4)        pop3c->eob++;      else        /* If the character match wasn't at position 1 or 4 then start the           search again */        pop3c->eob = 0;      break;    case 0x2e:      if(pop3c->eob == 2)        pop3c->eob++;      else if(pop3c->eob == 3) {        /* We have an extra dot after the CRLF which we need to strip off */        strip_dot = TRUE;        pop3c->eob = 0;      }      else        /* If the character match wasn't at position 2 then start the search           again */        pop3c->eob = 0;      break;    default:      pop3c->eob = 0;      break;    }    /* Did we have a partial match which has subsequently failed? */    if(prev && prev >= pop3c->eob) {      /* Strip can only be non-zero for the very first mismatch after CRLF         and then both prev and strip are equal and nothing will be output         below */      while(prev && pop3c->strip) {        prev--;        pop3c->strip--;      }      if(prev) {        /* If the partial match was the CRLF and dot then only write the CRLF           as the server would have inserted the dot */        result = Curl_client_write(conn, CLIENTWRITE_BODY, (char*)POP3_EOB,                                   strip_dot ? prev - 1 : prev);        if(result)          return result;        last = i;        strip_dot = FALSE;      }    }  }  if(pop3c->eob == POP3_EOB_LEN) {//.........这里部分代码省略.........
开发者ID:asm4096,项目名称:curl,代码行数:101,


示例6: Curl_httpchunk_read

/* * chunk_read() returns a OK for normal operations, or a positive return code * for errors. STOP means this sequence of chunks is complete.  The 'wrote' * argument is set to tell the caller how many bytes we actually passed to the * client (for byte-counting and whatever). * * The states and the state-machine is further explained in the header file. */CHUNKcode Curl_httpchunk_read(struct connectdata *conn,                              char *datap,                              ssize_t datalen,                              ssize_t *wrotep){    CURLcode result=CURLE_OK;    struct Curl_chunker *ch = &conn->proto.http->chunk;    struct Curl_transfer_keeper *k = &conn->keep;    size_t piece;    size_t length = (size_t)datalen;    size_t *wrote = (size_t *)wrotep;    *wrote = 0; /* nothing's written yet */    while(length) {        switch(ch->state) {        case CHUNK_HEX:            if(isxdigit((int)*datap)) {                if(ch->hexindex < MAXNUM_SIZE) {                    ch->hexbuffer[ch->hexindex] = *datap;                    datap++;                    length--;                    ch->hexindex++;                }                else {                    return CHUNKE_TOO_LONG_HEX; /* longer hex than we support */                }            }            else {                if(0 == ch->hexindex) {                    /* This is illegal data, we received junk where we expected                       a hexadecimal digit. */                    return CHUNKE_ILLEGAL_HEX;                }                /* length and datap are unmodified */                ch->hexbuffer[ch->hexindex]=0;                ch->datasize=strtoul(ch->hexbuffer, NULL, 16);                ch->state = CHUNK_POSTHEX;            }            break;        case CHUNK_POSTHEX:            /* In this state, we're waiting for CRLF to arrive. We support               this to allow so called chunk-extensions to show up here               before the CRLF comes. */            if(*datap == '/r')                ch->state = CHUNK_CR;            length--;            datap++;            break;        case CHUNK_CR:            /* waiting for the LF */            if(*datap == '/n') {                /* we're now expecting data to come, unless size was zero! */                if(0 == ch->datasize) {                    ch->state = CHUNK_STOP; /* stop reading! */                    if(1 == length) {                        /* This was the final byte, return right now */                        return CHUNKE_STOP;                    }                }                else                    ch->state = CHUNK_DATA;            }            else                /* previously we got a fake CR, go back to CR waiting! */                ch->state = CHUNK_CR;            datap++;            length--;            break;        case CHUNK_DATA:            /* we get pure and fine data               We expect another 'datasize' of data. We have 'length' right now,               it can be more or less than 'datasize'. Get the smallest piece.            */            piece = (ch->datasize >= length)?length:ch->datasize;            /* Write the data portion available */#ifdef HAVE_LIBZ            switch (conn->keep.content_encoding) {            case IDENTITY:#endif                if(!k->ignorebody)                    result = Curl_client_write(conn->data, CLIENTWRITE_BODY, datap,                                               piece);#ifdef HAVE_LIBZ                break;            case DEFLATE://.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:101,


示例7: inflate_stream

static CURLcodeinflate_stream(struct connectdata *conn,               struct SingleRequest *k){  int allow_restart = 1;  z_stream *z = &k->z;          /* zlib state structure */  uInt nread = z->avail_in;  Bytef *orig_in = z->next_in;  int status;                   /* zlib status */  CURLcode result = CURLE_OK;   /* Curl_client_write status */  char *decomp;                 /* Put the decompressed data here. */  /* Dynamically allocate a buffer for decompression because it's uncommonly     large to hold on the stack */  decomp = malloc(DSIZ);  if(decomp == NULL) {    return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);  }  /* because the buffer size is fixed, iteratively decompress and transfer to     the client via client_write. */  for(;;) {    /* (re)set buffer for decompressed output for every iteration */    z->next_out = (Bytef *)decomp;    z->avail_out = DSIZ;    status = inflate(z, Z_SYNC_FLUSH);    if(status == Z_OK || status == Z_STREAM_END) {      allow_restart = 0;      if((DSIZ - z->avail_out) && (!k->ignorebody)) {        result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,                                   DSIZ - z->avail_out);        /* if !CURLE_OK, clean up, return */        if(result) {          free(decomp);          return exit_zlib(z, &k->zlib_init, result);        }      }      /* Done? clean up, return */      if(status == Z_STREAM_END) {        free(decomp);        if(inflateEnd(z) == Z_OK)          return exit_zlib(z, &k->zlib_init, result);        else          return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));      }      /* Done with these bytes, exit */      /* status is always Z_OK at this point! */      if(z->avail_in == 0) {        free(decomp);        return result;      }    }    else if(allow_restart && status == Z_DATA_ERROR) {      /* some servers seem to not generate zlib headers, so this is an attempt         to fix and continue anyway */      (void) inflateEnd(z);     /* don't care about the return code */      if(inflateInit2(z, -MAX_WBITS) != Z_OK) {        free(decomp);        return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));      }      z->next_in = orig_in;      z->avail_in = nread;      allow_restart = 0;      continue;    }    else {                      /* Error; exit loop, handle below */      free(decomp);      return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));    }  }  /* Will never get here */}
开发者ID:karottc,项目名称:dtc_jd,代码行数:77,


示例8: Curl_proxyCONNECT

//.........这里部分代码省略.........                if(r == CHUNKE_STOP) {                  /* we're done reading chunks! */                  infof(data, "chunk reading DONE/n");                  keepon = FALSE;                  /* we did the full CONNECT treatment, go COMPLETE */                  conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;                }                else                  infof(data, "Read %zd bytes of chunk, continue/n",                        tookcareof);              }            }            else {              perline++; /* amount of bytes in this line so far */              if(*ptr == 0x0a) {                int writetype;                /* convert from the network encoding */                result = Curl_convert_from_network(data, line_start, perline);                /* Curl_convert_from_network calls failf if unsuccessful */                if(result)                  return result;                /* output debug if that is requested */                if(data->set.verbose)                  Curl_debug(data, CURLINFO_HEADER_IN,                             line_start, (size_t)perline, conn);                /* send the header to the callback */                writetype = CLIENTWRITE_HEADER;                if(data->set.include_header)                  writetype |= CLIENTWRITE_BODY;                result = Curl_client_write(conn, writetype, line_start,                                           perline);                data->info.header_size += (long)perline;                data->req.headerbytecount += (long)perline;                if(result)                  return result;                /* Newlines are CRLF, so the CR is ignored as the line isn't                   really terminated until the LF comes. Treat a following CR                   as end-of-headers as well.*/                if(('/r' == line_start[0]) ||                   ('/n' == line_start[0])) {                  /* end of response-headers from the proxy */                  nread = 0; /* make next read start over in the read                                buffer */                  ptr=data->state.buffer;                  if((407 == k->httpcode) && !data->state.authproblem) {                    /* If we get a 407 response code with content length                       when we have no auth problem, we must ignore the                       whole response-body */                    keepon = 2;                    if(cl) {                      infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T                            " bytes of response-body/n", cl);                    }                    else if(chunked_encoding) {                      CHUNKcode r;                      /* We set ignorebody true here since the chunked                         decoder function will acknowledge that. Pay
开发者ID:hunter-packages,项目名称:curl,代码行数:67,


示例9: curl_easy_pause

/* * curl_easy_pause() allows an application to pause or unpause a specific * transfer and direction. This function sets the full new state for the * current connection this easy handle operates on. * * NOTE: if you have the receiving paused and you call this function to remove * the pausing, you may get your write callback called at this point. * * Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h */CURLcode curl_easy_pause(CURL *curl, int action){  struct SessionHandle *data = (struct SessionHandle *)curl;  struct SingleRequest *k = &data->req;  CURLcode result = CURLE_OK;  /* first switch off both pause bits */  int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);  /* set the new desired pause bits */  newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |    ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0);  /* put it back in the keepon */  k->keepon = newstate;  if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) {    /* we have a buffer for sending that we now seem to be able to deliver since       the receive pausing is lifted! */    /* get the pointer, type and length in local copies since the function may       return PAUSE again and then we'll get a new copy allocted and stored in       the tempwrite variables */    char *tempwrite = data->state.tempwrite;    char *freewrite = tempwrite; /* store this pointer to free it later */    size_t tempsize = data->state.tempwritesize;    int temptype = data->state.tempwritetype;    size_t chunklen;    /* clear tempwrite here just to make sure it gets cleared if there's no       further use of it, and make sure we don't clear it after the function       invoke as it may have been set to a new value by then */    data->state.tempwrite = NULL;    /* since the write callback API is define to never exceed       CURL_MAX_WRITE_SIZE bytes in a single call, and since we may in fact       have more data than that in our buffer here, we must loop sending the       data in multiple calls until there's no data left or we get another       pause returned.       A tricky part is that the function we call will "buffer" the data       itself when it pauses on a particular buffer, so we may need to do some       extra trickery if we get a pause return here.    */    do {      chunklen = (tempsize > CURL_MAX_WRITE_SIZE)?CURL_MAX_WRITE_SIZE:tempsize;      result = Curl_client_write(data->state.current_conn,                                 temptype, tempwrite, chunklen);      if(result)        /* failures abort the loop at once */        break;      if(data->state.tempwrite && (tempsize - chunklen)) {        /* Ouch, the reading is again paused and the block we send is now           "cached". If this is the final chunk we can leave it like this, but           if we have more chunks that are cached after this, we need to free           the newly cached one and put back a version that is truly the entire           contents that is saved for later        */        char *newptr;        /* note that tempsize is still the size as before the callback was           used, and thus the whole piece of data to keep */        newptr = realloc(data->state.tempwrite, tempsize);        if(!newptr) {          free(data->state.tempwrite); /* free old area */          data->state.tempwrite = NULL;          result = CURLE_OUT_OF_MEMORY;          /* tempwrite will be freed further down */          break;        }        data->state.tempwrite = newptr; /* store new pointer */        memcpy(newptr, tempwrite, tempsize);        data->state.tempwritesize = tempsize; /* store new size */        /* tempwrite will be freed further down */        break; /* go back to pausing until further notice */      }      else {        tempsize -= chunklen;  /* left after the call above */        tempwrite += chunklen; /* advance the pointer */      }    } while((result == CURLE_OK) && tempsize);    free(freewrite); /* this is unconditionally no longer used */  }  return result;//.........这里部分代码省略.........
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:101,


示例10: Curl_ldap

//.........这里部分代码省略.........  rc = ldap_simple_bind_s(server,                          conn->bits.user_passwd ? conn->user : NULL,                          conn->bits.user_passwd ? conn->passwd : NULL);  if(!ldap_ssl && rc != 0) {    ldap_proto = LDAP_VERSION2;    ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);    rc = ldap_simple_bind_s(server,                            conn->bits.user_passwd ? conn->user : NULL,                            conn->bits.user_passwd ? conn->passwd : NULL);  }  if(rc != 0) {    failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));    status = CURLE_LDAP_CANNOT_BIND;    goto quit;  }  rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,                     ludp->lud_filter, ludp->lud_attrs, 0, &result);  if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {    failf(data, "LDAP remote: %s", ldap_err2string(rc));    status = CURLE_LDAP_SEARCH_FAILED;    goto quit;  }  for(num = 0, entryIterator = ldap_first_entry(server, result);      entryIterator;      entryIterator = ldap_next_entry(server, entryIterator), num++) {    BerElement *ber = NULL;    char  *attribute;       /*! suspicious that this isn't 'const' */    char  *dn = ldap_get_dn(server, entryIterator);    int i;    Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);    Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);    Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"/n", 1);    dlsize += strlen(dn)+5;    for(attribute = ldap_first_attribute(server, entryIterator, &ber);        attribute;        attribute = ldap_next_attribute(server, entryIterator, ber)) {      BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);      if(vals != NULL) {        for(i = 0; (vals[i] != NULL); i++) {          Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"/t", 1);          Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);          Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);          dlsize += strlen(attribute)+3;          if((strlen(attribute) > 7) &&              (strcmp(";binary",                      (char *)attribute +                      (strlen((char *)attribute) - 7)) == 0)) {            /* Binary attribute, encode to base64. */            CURLcode error = Curl_base64_encode(data,                                                vals[i]->bv_val,                                                vals[i]->bv_len,                                                &val_b64,                                                &val_b64_sz);            if(error) {              ldap_value_free_len(vals);              ldap_memfree(attribute);              ldap_memfree(dn);              if(ber)
开发者ID:Anomalous-Software,项目名称:CMake,代码行数:67,


示例11: imap_state_fetch_resp

/* For the (first line of) FETCH BODY[TEXT] response */static CURLcode imap_state_fetch_resp(struct connectdata *conn,                                      int imapcode,                                      imapstate instate){  CURLcode result = CURLE_OK;  struct SessionHandle *data = conn->data;  struct imap_conn *imapc = &conn->proto.imapc;  struct FTP *imap = data->state.proto.imap;  struct pingpong *pp = &imapc->pp;  const char *ptr = data->state.buffer;  (void)instate; /* no use for this yet */  if('*' != imapcode) {    Curl_pgrsSetDownloadSize(data, 0);    state(conn, IMAP_STOP);    return CURLE_OK;  }  /* Something like this comes "* 1 FETCH (BODY[TEXT] {2021}/r" */  while(*ptr && (*ptr != '{'))    ptr++;  if(*ptr == '{') {    curl_off_t filesize = curlx_strtoofft(ptr + 1, NULL, 10);    if(filesize)      Curl_pgrsSetDownloadSize(data, filesize);    infof(data, "Found %" FORMAT_OFF_TU " bytes to download/n", filesize);    if(pp->cache) {      /* At this point there is a bunch of data in the header "cache" that is         actually body content, send it as body and then skip it. Do note         that there may even be additional "headers" after the body. */      size_t chunk = pp->cache_size;      if(chunk > (size_t)filesize)        /* the conversion from curl_off_t to size_t is always fine here */        chunk = (size_t)filesize;      result = Curl_client_write(conn, CLIENTWRITE_BODY, pp->cache, chunk);      if(result)        return result;      filesize -= chunk;      /* we've now used parts of or the entire cache */      if(pp->cache_size > chunk) {        /* part of, move the trailing data to the start and reduce the size */        memmove(pp->cache, pp->cache+chunk,                pp->cache_size - chunk);        pp->cache_size -= chunk;      }      else {        /* cache is drained */        Curl_safefree(pp->cache);        pp->cache = NULL;        pp->cache_size = 0;      }    }    infof(data, "Filesize left: %" FORMAT_OFF_T "/n", filesize);    if(!filesize)      /* the entire data is already transferred! */      Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);    else      /* IMAP download */      Curl_setup_transfer(conn, FIRSTSOCKET, filesize, FALSE,                          imap->bytecountp, -1, NULL); /* no upload here */    data->req.maxdownload = filesize;  }  else    /* We don't know how to parse this line */    result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: fix this code */  /* End of do phase */  state(conn, IMAP_STOP);  return result;}
开发者ID:arsenm,项目名称:curl,代码行数:83,


示例12: Curl_sftp_do

//.........这里部分代码省略.........            remoteTime = (time_t)attrs.mtime;            nowParts = localtime(&remoteTime);            if ((time_t)attrs.mtime > (now - (3600 * 24 * 180))) {              currLen += snprintf(line+currLen, totalLen-currLen,                                  " %s %2d %2d:%02d", months[nowParts->tm_mon],                                  nowParts->tm_mday, nowParts->tm_hour,                                  nowParts->tm_min);            }            else {              currLen += snprintf(line+currLen, totalLen-currLen,                                  " %s %2d %5d", months[nowParts->tm_mon],                                  nowParts->tm_mday, 1900+nowParts->tm_year);            }          }          currLen += snprintf(line+currLen, totalLen-currLen, " %s", filename);          if ((attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&              ((attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==               LIBSSH2_SFTP_S_IFLNK)) {            char linkPath[PATH_MAX + 1];            snprintf(linkPath, PATH_MAX, "%s%s", sftp->path, filename);            len = libssh2_sftp_readlink(sftp->sftp_session, linkPath, filename,                                        PATH_MAX);            line = realloc(line, totalLen + 4 + len);            if (!line)              return CURLE_OUT_OF_MEMORY;            currLen += snprintf(line+currLen, totalLen-currLen, " -> %s",                                filename);          }          currLen += snprintf(line+currLen, totalLen-currLen, "/n");          res = Curl_client_write(conn, CLIENTWRITE_BODY, line, 0);          free(line);        }      }      libssh2_sftp_closedir(sftp->sftp_handle);      sftp->sftp_handle = NULL;      /* no data to transfer */      res = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);    }    else {      /*       * Work on getting the specified file       */      sftp->sftp_handle =        libssh2_sftp_open(sftp->sftp_session, sftp->path, LIBSSH2_FXF_READ,                          LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|                          LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);      if (!sftp->sftp_handle)        return CURLE_SSH;      if (libssh2_sftp_stat(sftp->sftp_session, sftp->path, &attrs)) {        /*         * 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;      }      else {        data->reqdata.size = attrs.filesize;        data->reqdata.maxdownload = attrs.filesize;        Curl_pgrsSetDownloadSize(data, attrs.filesize);
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:67,


示例13: telrcv

staticvoid telrcv(struct connectdata *conn,            unsigned char *inbuf,       /* Data received from socket */            ssize_t count)              /* Number of bytes received */{  unsigned char c;  int in = 0;  struct SessionHandle *data = conn->data;  struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet;  while(count--)  {    c = inbuf[in++];    switch (tn->telrcv_state)    {      case CURL_TS_CR:        tn->telrcv_state = CURL_TS_DATA;        if (c == '/0')        {          break;   /* Ignore /0 after CR */        }        Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);        continue;      case CURL_TS_DATA:        if (c == CURL_IAC)        {          tn->telrcv_state = CURL_TS_IAC;          break;        }        else if(c == '/r')        {          tn->telrcv_state = CURL_TS_CR;        }        Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);        continue;      case CURL_TS_IAC:      process_iac:      switch (c)      {        case CURL_WILL:          tn->telrcv_state = CURL_TS_WILL;          continue;        case CURL_WONT:          tn->telrcv_state = CURL_TS_WONT;          continue;        case CURL_DO:          tn->telrcv_state = CURL_TS_DO;          continue;        case CURL_DONT:          tn->telrcv_state = CURL_TS_DONT;          continue;        case CURL_SB:          CURL_SB_CLEAR(tn);          tn->telrcv_state = CURL_TS_SB;          continue;        case CURL_IAC:          Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);          break;        case CURL_DM:        case CURL_NOP:        case CURL_GA:        default:          printoption(data, "RCVD", CURL_IAC, c);          break;      }      tn->telrcv_state = CURL_TS_DATA;      continue;      case CURL_TS_WILL:        printoption(data, "RCVD", CURL_WILL, c);        tn->please_negotiate = 1;        rec_will(conn, c);        tn->telrcv_state = CURL_TS_DATA;        continue;      case CURL_TS_WONT:        printoption(data, "RCVD", CURL_WONT, c);        tn->please_negotiate = 1;        rec_wont(conn, c);        tn->telrcv_state = CURL_TS_DATA;        continue;      case CURL_TS_DO:        printoption(data, "RCVD", CURL_DO, c);        tn->please_negotiate = 1;        rec_do(conn, c);        tn->telrcv_state = CURL_TS_DATA;        continue;      case CURL_TS_DONT:        printoption(data, "RCVD", CURL_DONT, c);        tn->please_negotiate = 1;        rec_dont(conn, c);        tn->telrcv_state = CURL_TS_DATA;        continue;//.........这里部分代码省略.........
开发者ID:0-wiz-0,项目名称:CMake,代码行数:101,


示例14: curl_easy_pause

/* * curl_easy_pause() allows an application to pause or unpause a specific * transfer and direction. This function sets the full new state for the * current connection this easy handle operates on. * * NOTE: if you have the receiving paused and you call this function to remove * the pausing, you may get your write callback called at this point. * * Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h * * NOTE: This is one of few API functions that are allowed to be called from * within a callback. */CURLcode curl_easy_pause(struct Curl_easy *data, int action){  struct SingleRequest *k = &data->req;  CURLcode result = CURLE_OK;  /* first switch off both pause bits */  int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);  /* set the new desired pause bits */  newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |    ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0);  /* put it back in the keepon */  k->keepon = newstate;  if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempcount) {    /* there are buffers for sending that can be delivered as the receive       pausing is lifted! */    unsigned int i;    unsigned int count = data->state.tempcount;    struct tempbuf writebuf[3]; /* there can only be three */    struct connectdata *conn = data->conn;    struct Curl_easy *saved_data = NULL;    /* copy the structs to allow for immediate re-pausing */    for(i = 0; i < data->state.tempcount; i++) {      writebuf[i] = data->state.tempwrite[i];      data->state.tempwrite[i].buf = NULL;    }    data->state.tempcount = 0;    /* set the connection's current owner */    if(conn->data != data) {      saved_data = conn->data;      conn->data = data;    }    for(i = 0; i < count; i++) {      /* even if one function returns error, this loops through and frees all         buffers */      if(!result)        result = Curl_client_write(conn, writebuf[i].type, writebuf[i].buf,                                   writebuf[i].len);      free(writebuf[i].buf);    }    /* recover previous owner of the connection */    if(saved_data)      conn->data = saved_data;    if(result)      return result;  }  /* if there's no error and we're not pausing both directions, we want     to have this handle checked soon */  if(!result &&     ((newstate&(KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) !=      (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) )    Curl_expire(data, 0, EXPIRE_RUN_NOW); /* get this handle going again */  /* This transfer may have been moved in or out of the bundle, update     the corresponding socket callback, if used */  Curl_updatesocket(data);  return result;}
开发者ID:curl,项目名称:curl,代码行数:80,


示例15: Curl_httpchunk_read

/* * chunk_read() returns a OK for normal operations, or a positive return code * for errors. STOP means this sequence of chunks is complete.  The 'wrote' * argument is set to tell the caller how many bytes we actually passed to the * client (for byte-counting and whatever). * * The states and the state-machine is further explained in the header file. * * This function always uses ASCII hex values to accommodate non-ASCII hosts. * For example, 0x0d and 0x0a are used instead of '/r' and '/n'. */CHUNKcode Curl_httpchunk_read(struct connectdata *conn,                              char *datap,                              ssize_t datalen,                              ssize_t *wrotep){  CURLcode result=CURLE_OK;  struct SessionHandle *data = conn->data;  struct Curl_chunker *ch = &conn->chunk;  struct SingleRequest *k = &data->req;  size_t piece;  curl_off_t length = (curl_off_t)datalen;  size_t *wrote = (size_t *)wrotep;  *wrote = 0; /* nothing's written yet */  /* the original data is written to the client, but we go on with the     chunk read process, to properly calculate the content length*/  if(data->set.http_te_skip && !k->ignorebody) {    result = Curl_client_write(conn, CLIENTWRITE_BODY, datap, datalen);    if(result)      return CHUNKE_WRITE_ERROR;  }  while(length) {    switch(ch->state) {    case CHUNK_HEX:      if(Curl_isxdigit(*datap)) {        if(ch->hexindex < MAXNUM_SIZE) {          ch->hexbuffer[ch->hexindex] = *datap;          datap++;          length--;          ch->hexindex++;        }        else {          return CHUNKE_TOO_LONG_HEX; /* longer hex than we support */        }      }      else {        char *endptr;        if(0 == ch->hexindex)          /* This is illegal data, we received junk where we expected             a hexadecimal digit. */          return CHUNKE_ILLEGAL_HEX;        /* length and datap are unmodified */        ch->hexbuffer[ch->hexindex]=0;        /* convert to host encoding before calling strtoul */        result = Curl_convert_from_network(conn->data, ch->hexbuffer,                                           ch->hexindex);        if(result) {          /* Curl_convert_from_network calls failf if unsuccessful */          /* Treat it as a bad hex character */          return CHUNKE_ILLEGAL_HEX ;        }        ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16);        if(errno == ERANGE)          /* over or underflow is an error */          return CHUNKE_ILLEGAL_HEX;        ch->state = CHUNK_LF; /* now wait for the CRLF */      }      break;    case CHUNK_LF:      /* waiting for the LF after a chunk size */      if(*datap == 0x0a) {        /* we're now expecting data to come, unless size was zero! */        if(0 == ch->datasize) {          ch->state = CHUNK_TRAILER; /* now check for trailers */          conn->trlPos=0;        }        else          ch->state = CHUNK_DATA;      }      datap++;      length--;      break;    case CHUNK_DATA:      /* We expect 'datasize' of data. We have 'length' right now, it can be         more or less than 'datasize'. Get the smallest piece.      */      piece = curlx_sotouz((ch->datasize >= length)?length:ch->datasize);      /* Write the data portion available */#ifdef HAVE_LIBZ      switch (conn->data->set.http_ce_skip?//.........这里部分代码省略.........
开发者ID:1nfused,项目名称:RedPitaya,代码行数:101,


示例16: ldap_recv

static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,                         size_t len, CURLcode *err){  ldapconninfo *li = conn->proto.generic;  struct Curl_easy *data = conn->data;  ldapreqinfo *lr = data->req.protop;  int rc, ret;  LDAPMessage *msg = NULL;  LDAPMessage *ent;  BerElement *ber = NULL;  struct timeval tv = {0, 1};  (void)len;  (void)buf;  (void)sockindex;  rc = ldap_result(li->ld, lr->msgid, LDAP_MSG_RECEIVED, &tv, &msg);  if(rc < 0) {    failf(data, "LDAP local: search ldap_result %s", ldap_err2string(rc));    *err = CURLE_RECV_ERROR;    return -1;  }  *err = CURLE_AGAIN;  ret = -1;  /* timed out */  if(!msg)    return ret;  for(ent = ldap_first_message(li->ld, msg); ent;    ent = ldap_next_message(li->ld, ent)) {    struct berval bv, *bvals, **bvp = &bvals;    int binary = 0, msgtype;    CURLcode writeerr;    msgtype = ldap_msgtype(ent);    if(msgtype == LDAP_RES_SEARCH_RESULT) {      int code;      char *info = NULL;      rc = ldap_parse_result(li->ld, ent, &code, NULL, &info, NULL, NULL, 0);      if(rc) {        failf(data, "LDAP local: search ldap_parse_result %s",              ldap_err2string(rc));        *err = CURLE_LDAP_SEARCH_FAILED;      }      else if(code && code != LDAP_SIZELIMIT_EXCEEDED) {        failf(data, "LDAP remote: search failed %s %s", ldap_err2string(rc),              info ? info : "");        *err = CURLE_LDAP_SEARCH_FAILED;      }      else {        /* successful */        if(code == LDAP_SIZELIMIT_EXCEEDED)          infof(data, "There are more than %d entries/n", lr->nument);        data->req.size = data->req.bytecount;        *err = CURLE_OK;        ret = 0;      }      lr->msgid = 0;      ldap_memfree(info);      break;    }    else if(msgtype != LDAP_RES_SEARCH_ENTRY)      continue;    lr->nument++;    rc = ldap_get_dn_ber(li->ld, ent, &ber, &bv);    if(rc < 0) {      /* TODO: verify that this is really how this return code should be         handled */      *err = CURLE_RECV_ERROR;      return -1;    }    writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);    if(writeerr) {      *err = writeerr;      return -1;    }    writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,                                 bv.bv_len);    if(writeerr) {      *err = writeerr;      return -1;    }    writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"/n", 1);    if(writeerr) {      *err = writeerr;      return -1;    }    data->req.bytecount += bv.bv_len + 5;    for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);      rc == LDAP_SUCCESS;      rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp)) {      int i;      if(bv.bv_val == NULL) break;//.........这里部分代码省略.........
开发者ID:ArchangelSDY,项目名称:curl,代码行数:101,


示例17: file_do

/* * file_do() is the protocol-specific function for the do-phase, separated * from the connect-phase above. Other protocols merely setup the transfer in * the do-phase, to have it done in the main transfer loop but since some * platforms we support don't allow select()ing etc on file handles (as * opposed to sockets) we instead perform the whole do-operation in this * function. */static CURLcode file_do(struct connectdata *conn, bool *done){  /* This implementation ignores the host name in conformance with     RFC 1738. Only local files (reachable via the standard file system)     are supported. This means that files on remotely mounted directories     (via NFS, Samba, NT sharing) can be accessed through a file:// URL  */  CURLcode result = CURLE_OK;  struct_stat statbuf; /* struct_stat instead of struct stat just to allow the                          Windows version to have a different struct without                          having to redefine the simple word 'stat' */  curl_off_t expected_size=0;  bool size_known;  bool fstated=FALSE;  ssize_t nread;  struct Curl_easy *data = conn->data;  char *buf = data->state.buffer;  curl_off_t bytecount = 0;  int fd;  struct timeval now = Curl_tvnow();  struct FILEPROTO *file;  *done = TRUE; /* unconditionally */  Curl_initinfo(data);  Curl_pgrsStartNow(data);  if(data->set.upload)    return file_upload(conn);  file = conn->data->req.protop;  /* get the fd from the connection phase */  fd = file->fd;  /* VMS: This only works reliable for STREAMLF files */  if(-1 != fstat(fd, &statbuf)) {    /* we could stat it, then read out the size */    expected_size = statbuf.st_size;    /* and store the modification time */    data->info.filetime = (long)statbuf.st_mtime;    fstated = TRUE;  }  if(fstated && !data->state.range && data->set.timecondition) {    if(!Curl_meets_timecondition(data, (time_t)data->info.filetime)) {      *done = TRUE;      return CURLE_OK;    }  }  /* If we have selected NOBODY and HEADER, it means that we only want file     information. Which for FILE can't be much more than the file size and     date. */  if(data->set.opt_no_body && data->set.include_header && fstated) {    time_t filetime;    struct tm buffer;    const struct tm *tm = &buffer;    snprintf(buf, sizeof(data->state.buffer),             "Content-Length: %" CURL_FORMAT_CURL_OFF_T "/r/n", expected_size);    result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);    if(result)      return result;    result = Curl_client_write(conn, CLIENTWRITE_BOTH,                               (char *)"Accept-ranges: bytes/r/n", 0);    if(result)      return result;    filetime = (time_t)statbuf.st_mtime;    result = Curl_gmtime(filetime, &buffer);    if(result)      return result;    /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */    snprintf(buf, BUFSIZE-1,             "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT/r/n",             Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],             tm->tm_mday,             Curl_month[tm->tm_mon],             tm->tm_year + 1900,             tm->tm_hour,             tm->tm_min,             tm->tm_sec);    result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);    if(!result)      /* set the file size to make it available post transfer */      Curl_pgrsSetDownloadSize(data, expected_size);    return result;  }  /* Check whether file range has been specified *///.........这里部分代码省略.........
开发者ID:Unity-Technologies,项目名称:curl,代码行数:101,


示例18: Curl_httpchunk_read

//.........这里部分代码省略.........               /* This is the final byte, return right now */               return CHUNKE_STOP;            }          }          else {            ch->state = CHUNK_TRAILER; /* attempt to read trailers */            conn->trlPos=0;          }        }        else          ch->state = CHUNK_DATA;      }      else        /* previously we got a fake CR, go back to CR waiting! */        ch->state = CHUNK_CR;      datap++;      length--;      break;    case CHUNK_DATA:      /* we get pure and fine data         We expect another 'datasize' of data. We have 'length' right now,         it can be more or less than 'datasize'. Get the smallest piece.      */      piece = (ch->datasize >= length)?length:ch->datasize;      /* Write the data portion available */#ifdef HAVE_LIBZ      switch (data->reqdata.keep.content_encoding) {        case IDENTITY:#endif          if(!k->ignorebody)            result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,                                       piece);#ifdef HAVE_LIBZ          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,                                               (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,                                            (ssize_t)piece);          break;        case COMPRESS:        default:          failf (conn->data,                 "Unrecognized content encoding type. "                 "libcurl understands `identity', `deflate' and `gzip' "                 "content encodings.");          return CHUNKE_BAD_ENCODING;      }#endif      if(result)        return CHUNKE_WRITE_ERROR;      *wrote += piece;
开发者ID:0-wiz-0,项目名称:CMake,代码行数:67,



注:本文中的Curl_client_write函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ Curl_closesocket函数代码示例
C++ Curl_base64_encode函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。