cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Port from URI is not taken

From: Sidde Gowda <engowdre_at_hotmail.com>
Date: Thu, 30 Aug 2012 20:34:11 +0000

> Date: Thu, 30 Aug 2012 22:18:06 +0200
> From: daniel_at_haxx.se
> To: curl-library_at_cool.haxx.se
> Subject: Re: Port from URI is not taken
>
> On Thu, 30 Aug 2012, Sidde Gowda wrote:
>
> > Using port 80, I am getting the html content instead of intended file.
>
> Using a proxy? Otherwise, can you please show us a complete example code that
> repeats this problem for you. Which libcurl version on what OS?
>
> --
>
> / daniel.haxx.se

I am not using proxy. Version is 7.22.0 on QNX6

/*
 * http_curl_setopt_perform
 */
static fetchd_rc_t
http_curl_setopt_perform (CURL *curl,
                          FILE *file,
                          fetchd_client_msg_t *msg)
{
#ifdef DEBUG_FETCH
    char buf[FETCHD_MAX_ERRBUF_LEN];
#endif
    char srv_cert[FETCHD_MAX_SRVRCERT_LEN];
    uint16_t port;
    CURLcode curl_rc;
    fetchd_rc_t fetchd_rc = FETCHD_RC_OK;
    bool http_need_ssltls = false;

    if (msg == NULL) {
        fetchd_rc = FETCHD_RC_INVALID_MSG;
        return(fetchd_rc);
    }

    /* parse url and resolve name if needed */
    fetchd_rc = http_curl_parse_resolve_url(msg->frm_ctx_idx,
                                            msg->frm_url,
                                            &port,
                                            &http_need_ssltls);
    if (fetchd_rc != FETCHD_RC_OK) {
        return(fetchd_rc);
    }

#ifdef DEBUG_FETCH
    curl_rc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "VERBOSE failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buf);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "ERRORBUFFER failed %d", curl_rc);
#endif

    curl_rc = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "NOPROGRESS failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_URL, msg->frm_url);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "URL failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "HEADER failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_PORT, port);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "PORT failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "FOLLOWLOCATION failed %d", curl_rc);

    //curl_rc = curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
    /* ASSERT_CLASS_LOGICAL */
    //nv_assert(curl_rc == CURLE_OK, "WILDCARDMATCH failed %d", curl_rc);

    if (http_need_ssltls) {
        fetchd_rc = http_curl_find_ssltls_cert(msg->frm_ctx_name,
                                               srv_cert);
        if (fetchd_rc != FETCHD_RC_OK) {
            return(fetchd_rc);
        }

        /* Transport Layer Security (TLS) for https service */
        curl_rc = curl_easy_setopt(curl, CURLOPT_USE_SSL,
                                   (long)CURLUSESSL_ALL);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "USE_SSL failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "VERIFYPEER failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "VERIFYHOST failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_CAINFO, srv_cert);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "CAINFO failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "SSLCERTTYPE failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION,
                                   http_curl_ssl_ctx);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "CTX_FUNCTION failed %d", curl_rc);

        curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, NULL);
        /* ASSERT_CLASS_LOGICAL */
        nv_assert(curl_rc == CURLE_OK, "CTX_DATA failed %d", curl_rc);
    }

    /* call this function to get a socket */
    curl_rc = curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION,
                               http_curl_open_socket);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "OPENSOCKETFUNCTION failed %d", curl_rc);

    curl_rc = curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA,
                               (void *)msg->frm_ctx_idx);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "OPENSOCKETDATA failed %d", curl_rc);

    /* write to the file */
    //curl_rc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
    // http_curl_write_data);
    /* ASSERT_CLASS_LOGICAL */
    //nv_assert(curl_rc == CURLE_OK, "WRITEFUNCTION failed %d", curl_rc);

    /* write to the file */
    curl_rc = curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
    /* ASSERT_CLASS_LOGICAL */
    nv_assert(curl_rc == CURLE_OK, "WRITEDATA failed %d", curl_rc);

    /* perform the curl request */
    curl_rc = http_curl_perform(curl);
    if (curl_rc != CURLE_OK) {
#ifdef DEBUG_FETCH
        evl_fetchd_log_general("%s: error [rc %u] buf [%s]",
                               __FUNCTION__, curl_rc, buf);
#endif
        fetchd_rc = FETCHD_RC_CURL_PERFORM_FAIL;
    }

    return(fetchd_rc);
}

> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
                                               

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-08-30