cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl-library Digest, Vol 127, Issue 4

From: ravi kumar via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 2 Mar 2016 11:25:11 +0000 (UTC)

Hello sir,Thanks for your reply. 
  struct curl_slist *header_list = NULL;
   header_list = curl_slist_append(header_list, your_header_here);
   header_list = curl_slist_append(header_list, your_next_header_here);
   curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
   curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
Here when i am passing xml file contect it passess correctly.Means i am reading from a file fread in unsigned char *buf.
and using in curl_easy_setopt(curl, CURLOPT_HTTPHEADER, buf);curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); ,it works and able to see header in termainal. But when i am encoding in base64 by using own program

unsigned char * base64_encode(const unsigned char *src, size_t len,
                  size_t *out_len)
{
    unsigned char *out, *pos;
    const unsigned char *end, *in;
    size_t olen;
    int line_len;

    olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
    olen += olen / 72; /* line feeds */
    olen++; /* nul termination */
    out = malloc(olen);
    if (out == NULL)
        return NULL;

    end = src + len;
    in = src;
    pos = out;
    line_len = 0;
    while (end - in >= 3) {
        *pos++ = base64_table[in[0] >> 2];
        *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
        *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
        *pos++ = base64_table[in[2] & 0x3f];
        in += 3;
        line_len += 4;
        if (line_len >= 72) {
            *pos++ = '\n';
            line_len = 0;
        }
    }

    if (end - in) {
        *pos++ = base64_table[in[0] >> 2];
        if (end - in == 1) {
            *pos++ = base64_table[(in[0] & 0x03) << 4];
            *pos++ = '=';
        } else {
            *pos++ = base64_table[((in[0] & 0x03) << 4) |
                          (in[1] >> 4)];
            *pos++ = base64_table[(in[1] & 0x0f) << 2];
        }
        *pos++ = '=';
        line_len += 4;
    }

    if (line_len)
        *pos++ = '\n';

    *pos = '\0';
    if (out_len)
        *out_len = pos - out;
    return out;
} and using
e = base64_encode(buf, len, &elen); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, e);curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);It not works and shows in header blanck in termainal.
I have to pass data in base64 encoded form.So,what should be problem.how will i use library for base64.I found curl have API to encoding also but not able to understand the format types like gzip
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip");curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING,1L);So,please let me know where is problem and how will use libcurl API for base64 encoding.

ThanksRavi Kumar

 

    On Wednesday, March 2, 2016 4:34 PM, "curl-library-request_at_cool.haxx.se" <curl-library-request_at_cool.haxx.se> wrote:
 

 Send curl-library mailing list submissions to
    curl-library_at_cool.haxx.se

To subscribe or unsubscribe via the World Wide Web, visit
    http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
or, via email, send a message with subject or body 'help' to
    curl-library-request_at_cool.haxx.se

You can reach the person managing the list at
    curl-library-owner_at_cool.haxx.se

When replying, please edit your Subject line so it is more specific
than "Re: Contents of curl-library digest..."

Today's Topics:

  1. Re: Fw: problem_in_header (Ray Satiro)
  2. Recommended architecture for streaming over multiple sockets
      (Boutin Maël)
  3. Massive HTTP/2 parallel requests (Molina)

----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 01:20:38 -0500
From: Ray Satiro <raysatiro_at_yahoo.com>
To: curl-library_at_cool.haxx.se
Subject: Re: Fw: problem_in_header
Message-ID: <56D68636.3090508_at_yahoo.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

On 3/1/2016 1:42 PM, ravi kumar via curl-library wrote:
> I have xml file.I have to post the data of xml file.
> Now in our server, we have to send  base64encode data in header.which
> i am trying by using CURLOPT_HEADERFUCNCTION and
> CURLOPT_HEADERDATA,which not able to pass in header.
> Means i have to pass data in header,you can see the attached image and
> program.
>

The header function is called for each received header and it has
nothing to do with headers to be sent. To send encoded data in a header
use CURLOPT_HTTPHEADER [1] not the header function. It is possible the
headers to be sent could go to a proxy as well on CONNECT by default
depending on how old your version of libcurl is. This may not be what
you intended if the data is secret. In that case use CURLOPT_HEADEROPT
[2] as well if necessary.

  struct curl_slist *header_list = NULL;
  header_list = curl_slist_append(header_list, your_header_here);
  header_list = curl_slist_append(header_list, your_next_header_here);
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
  curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);

after the transfer is finished call curl_slist_free_all(header_list);

I suggest you contact connect2 if their server still does not
acknowledge your request after sending the proper headers.

[1]: https://curl.haxx.se/libcurl/c/CURLOPT_HTTPHEADER.html
[2]: https://curl.haxx.se/libcurl/c/CURLOPT_HEADEROPT.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cool.haxx.se/pipermail/curl-library/attachments/20160302/c3dd8a82/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 2 Mar 2016 09:28:38 +0100
From: Boutin Maël <mael.boutin_at_gmail.com>
To: libcurl development <curl-library_at_cool.haxx.se>
Subject: Recommended architecture for streaming over multiple sockets
Message-ID:
    <CABuRF=ya98HxzKe8GJdqc7xvP=EHwiH+La=q8D_3RWGxEsdp2Q_at_mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi folks,

I'm currently using libcurl to send data over a nginx local server using
HTTP POST and transfer-encoding chunked.

My application is fed with buffers which i have to send as soon as i get
them. These buffers may belong to various endpoints on the nginx server.

My question is, what use of libcurl would you recommend for this task. I
saw two options:
1. Multiple threads
I'd have one thread with a FIFO queue that would get the buffers and get a
thread from a pool. This thread would then send the buffer to nginx
2. One thread and multi interface
I'd here work in non blocking mode with the multi interface. I'm not sure
how i'd have to implement it and it seems quite overkill to me.

Technical notes that may direct your answer:
* The connection with the server must not be closed even if there are no
more data to send.
* If we cannot send data on the connection that it must be closed and
reopened.

Thanks in advance,

Regards,

-- 
Maël BOUTIN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cool.haxx.se/pipermail/curl-library/attachments/20160302/de25194b/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 2 Mar 2016 10:46:56 +0100
From: Molina <jose.molina_at_cern.ch>
To: <curl-library_at_cool.haxx.se>
Subject: Massive HTTP/2 parallel requests
Message-ID: <81704C9D-42A0-4675-B61D-5F3E346D333E_at_cern.ch>
Content-Type: text/plain; charset="utf-8"
Hello,
I’m working in a project that downloads a decent amount of files simultaneously, with an average size of 512KB. We’ve been using CURL with HTTP/1.1 requests so far, and I’ve been modifying the code to adapt it to HTTP/2.0. However, when trying to simultaneously download 1024 files for testing I realised only 64 where actually active, while the rest were idle. I was using only one multiplexed connection with CURLOPT_PIPEWAIT enabled.
Secondly, just in order to try I set the following flags:
  curl_multi_setopt(multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS , 1024);
  curl_multi_setopt(multi_handle, CURLMOPT_MAX_HOST_CONNECTIONS, 1024);
Which apparently enabled multiple 64-file-wide HTTP/2.0 connections, where each one received the corresponding “101, switching protocols” answer.
Is this limit something desirable or convenient for the performance of HTTP/2.0? Would you have an advice for this use case?
Thanks a lot in advance, and best regards.
José Molina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://cool.haxx.se/pipermail/curl-library/attachments/20160302/1b1a9104/attachment-0001.sig>
------------------------------
Subject: Digest Footer
_______________________________________________
curl-library mailing list
curl-library_at_cool.haxx.se
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
------------------------------
End of curl-library Digest, Vol 127, Issue 4
********************************************
  

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-03-02