Giter Club home page Giter Club logo

curl-rust's Introduction

curl-rust

libcurl bindings for Rust

Latest Version Documentation License Build

Quick Start

use std::io::{stdout, Write};

use curl::easy::Easy;

// Print a web page onto stdout
fn main() {
    let mut easy = Easy::new();
    easy.url("https://www.rust-lang.org/").unwrap();
    easy.write_function(|data| {
        stdout().write_all(data).unwrap();
        Ok(data.len())
    }).unwrap();
    easy.perform().unwrap();

    println!("{}", easy.response_code().unwrap());
}
use curl::easy::Easy;

// Capture output into a local `Vec`.
fn main() {
    let mut dst = Vec::new();
    let mut easy = Easy::new();
    easy.url("https://www.rust-lang.org/").unwrap();

    let mut transfer = easy.transfer();
    transfer.write_function(|data| {
        dst.extend_from_slice(data);
        Ok(data.len())
    }).unwrap();
    transfer.perform().unwrap();
}

Post / Put requests

The put and post methods on Easy can configure the method of the HTTP request, and then read_function can be used to specify how data is filled in. This interface works particularly well with types that implement Read.

use std::io::Read;
use curl::easy::Easy;

fn main() {
    let mut data = "this is the body".as_bytes();

    let mut easy = Easy::new();
    easy.url("http://www.example.com/upload").unwrap();
    easy.post(true).unwrap();
    easy.post_field_size(data.len() as u64).unwrap();

    let mut transfer = easy.transfer();
    transfer.read_function(|buf| {
        Ok(data.read(buf).unwrap_or(0))
    }).unwrap();
    transfer.perform().unwrap();
}

Custom headers

Custom headers can be specified as part of the request:

use curl::easy::{Easy, List};

fn main() {
    let mut easy = Easy::new();
    easy.url("http://www.example.com").unwrap();

    let mut list = List::new();
    list.append("Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==").unwrap();
    easy.http_headers(list).unwrap();
    easy.perform().unwrap();
}

Keep alive

The handle can be re-used across multiple requests. Curl will attempt to keep the connections alive.

use curl::easy::Easy;

fn main() {
    let mut handle = Easy::new();

    handle.url("http://www.example.com/foo").unwrap();
    handle.perform().unwrap();

    handle.url("http://www.example.com/bar").unwrap();
    handle.perform().unwrap();
}

Multiple requests

The libcurl library provides support for sending multiple requests simultaneously through the "multi" interface. This is currently bound in the multi module of this crate and provides the ability to execute multiple transfers simultaneously. For more information, see that module.

Building

By default, this crate will attempt to dynamically link to the system-wide libcurl and the system-wide SSL library. Some of this behavior can be customized with various Cargo features:

  • ssl: Enable SSL/TLS support using the platform-default TLS backend. On Windows this is Schannel, on macOS Secure Transport, and OpenSSL (or equivalent) on all other platforms. Enabled by default.

  • rustls Enable SSL/TLS support via Rustls, a well-received alternative TLS backend written in Rust. Rustls is always statically linked. Disabled by default.

    Note that Rustls support is experimental within Curl itself and may have significant bugs, so we don't offer any sort of stability guarantee with this feature.

  • http2: Enable HTTP/2 support via libnghttp2. Disabled by default.

  • static-curl: Use a bundled libcurl version and statically link to it. Disabled by default.

  • static-ssl: Use a bundled OpenSSL version and statically link to it. Only applies on platforms that use OpenSSL. Disabled by default.

  • spnego: Enable SPNEGO support. Disabled by default.

  • upkeep_7_62_0: Enable curl_easy_upkeep() support, introduced in curl 7.62.0. Disabled by default.

  • poll_7_68_0: Enable curl_multi_poll()/curl_multi_wakeup() support, requires curl 7.68.0 or later. Disabled by default.

  • ntlm: Enable NTLM support in curl. Disabled by default.

  • windows-static-ssl: Enable Openssl support on Windows via the static build provided by vcpkg. Incompatible with ssl (use --no-default-features). Disabled by default.

    Note that to install openssl on windows via vcpkg the following commands needs to be ran:

    git clone https://github.com/microsoft/vcpkg
    cd vcpkg
    ./bootstrap-vcpkg.bat -disableMetrics
    ./vcpkg.exe integrate install
    ./vcpkg.exe install openssl:x64-windows-static-md

Version Support

The bindings have been developed using curl version 7.24.0. They should work with any newer version of curl and possibly with older versions, but this has not been tested.

Troubleshooting

Curl built against the NSS SSL library

If you encounter the following error message:

  [77] Problem with the SSL CA cert (path? access rights?)

That means most likely, that curl was linked against libcurl-nss.so due to installed libcurl NSS development files, and that the required library libnsspem.so is missing. See also the curl man page: "If curl is built against the NSS SSL library, the NSS PEM PKCS#11 module (libnsspem.so) needs to be available for this option to work properly."

In order to avoid this failure you can either

  • install the missing library (e.g. Debian: nss-plugin-pem), or
  • remove the libcurl NSS development files (e.g. Debian: libcurl4-nss-dev) and rebuild curl-rust.

License

The curl-rust crate is licensed under the MIT license, see LICENSE for more details.

curl-rust's People

Contributors

akosthekiss avatar aldanor avatar alexcrichton avatar carllerche avatar darkprokoba avatar dependabot-preview[bot] avatar ecnelises avatar ehuss avatar gifnksm avatar globin avatar hvenev avatar ishitatsuyuki avatar jcamiel avatar kaknife avatar kstep avatar kulshrax avatar lluchs avatar lorenzoleonardo avatar maxdymond avatar mcgoo avatar mneumann avatar nielx avatar overminder avatar sagebind avatar simonvandel avatar theawless avatar tshepang avatar waldemarnt avatar weihanglo avatar winterqt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

curl-rust's Issues

Use of '`pthread' fails in Windows 32bits

I come across this error when trying to compile on Windows 32bits. I have MSYS2 installed. It seems that 'pthread' is not supported by MSYS2 / mingw32.

error: linking with gcc failed: exit code: 1
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1a3): undefined reference to pthread_mutex_init' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfd9): undefined reference topthread_once'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfe5): undefined reference to pthread_mutex_lock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10f4): undefined reference topthread_once'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1100): undefined reference to pthread_mutex_lock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x11cb): undefined reference topthread_once'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x11d7): undefined reference to pthread_mutex_lock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1239): undefined reference topthread_mutex_unlock'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1268): undefined reference to pthread_mutex_unlock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12ef): undefined reference topthread_once'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12fb): undefined reference to pthread_mutex_lock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1337): undefined reference topthread_mutex_unlock'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x13f6): undefined reference to pthread_mutex_unlock' D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1004): undefined reference topthread_mutex_unlock'
D:/Applications/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x111f): undefined reference to `pthread_mutex_unlock'
collect2.exe: error: ld returned 1 exit status

Could there be something I missed in my install?
I cannot find much about this error online except that this function is not on Windows.

Make `Response` Public

Hey, I was wondering if you had a reason for response not being public.

I'm working on a library agnostic OAuth implementation and feel it would be cleaner to return a Response object opposed to opposed to a struct containing the equivalent data in my example cases

Thanks!

compilation error with stderr

What depedencies do I need to install?

failed to run custom build command for `curl-sys v0.1.20`
Process didn't exit successfully: `/source/target/debug/build/curl-sys-19ec055fea136d2a/build-script-build` (exit code: 101)
--- stdout
running: "sh" "-c" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-sys-0.1.20/curl/configure --without-ca-bundle --without-ca-path --enable-static=yes --enable-shared=no --enable-optimize --prefix=/source/target/debug/build/curl-sys-19ec055fea136d2a/out --without-librtmp --without-libidn --without-libssh2 --without-nghttp2 --disable-ldap --disable-ldaps --disable-ftp --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual"
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking for path separator... :
checking for sed... /bin/sed
checking for grep... /bin/grep
checking for egrep... /bin/grep -E
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... no
checking for style of include used by make... none
checking whether make supports nested variables... no
checking dependency style of gcc... none
checking curl version... 7.39.1-DEV
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for sys/types.h... yes
checking for stdint.h... yes
checking for inttypes.h... yes
checking for grep that handles long lines and -e... (cached) /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for unistd.h... yes
checking size of long... 8
checking size of void*... 8
checking for 64-bit curl_off_t data type... long
checking size of curl_off_t... 8
checking formatting string directive for curl_off_t... "ld"
checking formatting string directive for unsigned curl_off_t... "lu"
checking constant suffix string for curl_off_t... L
checking constant suffix string for unsigned curl_off_t... UL
checking if OS is AIX (to define _ALL_SOURCE)... no
checking if _THREAD_SAFE is already defined... no
checking if _THREAD_SAFE is actually needed... no
checking if _THREAD_SAFE is onwards defined... no
checking if _REENTRANT is already defined... no
checking if _REENTRANT is actually needed... no
checking if _REENTRANT is onwards defined... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether to build shared libraries with -version-info... yes
checking whether to build shared libraries with -no-undefined... no
checking whether to build shared libraries with -mimpure-text... no
checking whether to build shared libraries with PIC... yes
checking whether to build static libraries with PIC... yes
checking whether to build shared libraries only... no
checking whether to build static libraries only... yes
checking for inline... inline
checking if compiler is DEC/Compaq/HP C... no
checking if compiler is HP-UX C... no
checking if compiler is IBM C... no
checking if compiler is Intel C... no
checking if compiler is clang... no
checking if compiler is GNU C... yes
checking if compiler is LCC... no
checking if compiler is SGI MIPSpro C... no
checking if compiler is SGI MIPS C... no
checking if compiler is SunPro C... no
checking if compiler is Tiny C... no
checking if compiler is Watcom C... no
checking if compiler accepts debug disabling options... yes
configure: compiler options added: 
checking if compiler accepts optimizer enabling options... yes
configure: compiler options added: -O2
checking if compiler accepts strict warning options... yes
configure: compiler options added: -Wno-system-headers 
checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... yes
checking if compiler supports hiding library internal symbols... yes
checking for windows.h... no
checking whether build target is a native Windows one... no
checking whether build target supports WIN32 file API... no
checking whether to support http... yes
checking whether to support ftp... no
checking whether to support file... yes
checking whether to support ldap... no
checking whether to support ldaps... no
checking whether to support rtsp... no
checking whether to support proxies... yes
checking whether to support dict... no
checking whether to support telnet... no
checking whether to support tftp... no
checking whether to support pop3... no
checking whether to support imap... no
checking whether to support smtp... no
checking whether to support gopher... no
checking whether to provide built-in manual... no
checking whether to enable generation of C code... yes
checking whether to use libgcc... no
checking if X/Open network library is required... no
checking for gethostbyname... yes
checking for strcasecmp... yes
checking for windows.h... (cached) no
checking for winsock.h... (cached) no
checking for winsock2.h... (cached) no
checking for connect in libraries... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/types.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for monotonic clock_gettime... yes
checking for clock_gettime in libraries... no additional lib required
checking if monotonic clock_gettime works... yes
checking for inflateEnd in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
configure: found both libz and libz.h header
checking whether to enable ipv6... yes
checking if struct sockaddr_in6 has sin6_scope_id member... yes
checking if argv can be written to... yes
checking if GSS-API support is requested... no
checking whether to enable Windows native SSL/TLS (Windows native builds only)... no
checking whether to enable iOS/Mac OS X native SSL/TLS... no
checking for pkg-config... no
checking for CRYPTO_lock in -lcrypto... yes
checking for SSL_connect in -lssl... yes
checking openssl/x509.h usability... yes
checking openssl/x509.h presence... yes
checking for openssl/x509.h... yes
checking openssl/rsa.h usability... yes
checking openssl/rsa.h presence... yes
checking for openssl/rsa.h... yes
checking openssl/crypto.h usability... yes
checking openssl/crypto.h presence... yes
checking for openssl/crypto.h... yes
checking openssl/pem.h usability... yes
checking openssl/pem.h presence... yes
checking for openssl/pem.h... yes
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... yes
checking for openssl/ssl.h... yes
checking openssl/err.h usability... yes
checking openssl/err.h presence... yes
checking for openssl/err.h... yes
checking openssl/pkcs12.h usability... yes
checking openssl/pkcs12.h presence... yes
checking for openssl/pkcs12.h... yes
checking for ENGINE_init... yes
checking openssl/engine.h usability... yes
checking openssl/engine.h presence... yes
checking for openssl/engine.h... yes
checking for ENGINE_load_builtin_engines... yes
checking for RAND_status... yes
checking for RAND_screen... no
checking for RAND_egd... yes
checking for ENGINE_cleanup... yes
checking for CRYPTO_cleanup_all_ex_data... yes
checking for SSL_get_shutdown... yes
checking for SSLv2_client_method... no
checking for yaSSL using OpenSSL compatibility mode... no
checking for OpenSSL headers version... 1.0.1 - 0x100010bfL
checking for OpenSSL library version... 1.0.1
checking for OpenSSL headers and library versions matching... yes
checking for "/dev/urandom"... yes
checking for SRP_Calc_client_key in -lcrypto... yes
checking default CA cert bundle/path... no
checking whether versioned symbols are wanted... no
checking whether to enable Windows native IDN (Windows native builds only)... no
checking whether to build with libidn... no
checking for ANSI C header files... (cached) yes
checking for malloc.h... yes
checking for memory.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/select.h... yes
checking for sys/socket.h... yes
checking for sys/ioctl.h... yes
checking for sys/uio.h... yes
checking for assert.h... yes
checking for unistd.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for limits.h... yes
checking for arpa/inet.h... yes
checking for net/if.h... yes
checking for netinet/in.h... yes
checking for sys/un.h... yes
checking for netinet/tcp.h... yes
checking for netdb.h... yes
checking for sys/sockio.h... no
checking for sys/stat.h... (cached) yes
checking for sys/param.h... yes
checking for termios.h... yes
checking for termio.h... yes
checking for sgtty.h... yes
checking for fcntl.h... yes
checking for alloca.h... yes
checking for time.h... (cached) yes
checking for io.h... no
checking for pwd.h... yes
checking for utime.h... yes
checking for sys/utime.h... no
checking for sys/poll.h... yes
checking for poll.h... yes
checking for socket.h... no
checking for sys/resource.h... yes
checking for libgen.h... yes
checking for locale.h... yes
checking for errno.h... yes
checking for stdbool.h... yes
checking for arpa/tftp.h... yes
checking for sys/filio.h... no
checking for sys/wait.h... yes
checking for setjmp.h... yes
checking for an ANSI C-conforming const... yes
checking for compiler support of C99 variadic macro style... yes
checking for compiler support of old gcc variadic macro style... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for time.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for struct timeval... yes
checking run-time libs availability... fine
checking size of size_t... 8
checking size of long... (cached) 8
checking size of int... 4
checking size of short... 2
checking size of time_t... 8
checking size of off_t... 8
checking for long long... yes
checking if numberLL works... yes
checking for ssize_t... yes
checking for bool... yes
checking for windows.h... (cached) no
checking for winsock2.h... (cached) no
checking for ws2tcpip.h... (cached) no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for curl_socklen_t data type... socklen_t
checking size of curl_socklen_t... 4
checking for sys/types.h... (cached) yes
checking for poll.h... (cached) yes
checking for sys/poll.h... (cached) yes
checking for in_addr_t... yes
checking for struct sockaddr_storage... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for sig_atomic_t... yes
checking if sig_atomic_t is already defined as volatile... no
checking return type of signal handlers... void
checking for sys/select.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for select... yes
checking types of args and return type for select... int,fd_set *,struct timeval *,int
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for recv... yes
checking types of args and return type for recv... int,void *,size_t,int,ssize_t
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for send... yes
checking types of args and return type for send... int,const void *,size_t,int,ssize_t
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for MSG_NOSIGNAL... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking if alarm can be linked... yes
checking if alarm is prototyped... yes
checking if alarm is compilable... yes
checking if alarm usage allowed... yes
checking if alarm might be used... yes
checking for sys/types.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for libgen.h... (cached) yes
checking if basename can be linked... yes
checking if basename is prototyped... yes
checking if basename is compilable... yes
checking if basename usage allowed... yes
checking if basename might be used... yes
checking for sys/types.h... (cached) yes
checking for socket.h... (cached) no
checking if closesocket can be linked... no
checking if closesocket might be used... no
checking if CloseSocket can be linked... no
checking if CloseSocket might be used... no
checking if connect can be linked... yes
checking if connect is prototyped... yes
checking if connect is compilable... yes
checking if connect usage allowed... yes
checking if connect might be used... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for fcntl.h... (cached) yes
checking if fcntl can be linked... yes
checking if fcntl is prototyped... yes
checking if fcntl is compilable... yes
checking if fcntl usage allowed... yes
checking if fcntl might be used... yes
checking if fcntl O_NONBLOCK is compilable... yes
checking if fcntl O_NONBLOCK usage allowed... yes
checking if fcntl O_NONBLOCK might be used... yes
checking for sys/types.h... (cached) yes
checking for stdio.h... yes
checking if fdopen can be linked... yes
checking if fdopen is prototyped... yes
checking if fdopen is compilable... yes
checking if fdopen usage allowed... yes
checking if fdopen might be used... yes
checking for sys/types.h... (cached) yes
checking for netdb.h... (cached) yes
checking if freeaddrinfo can be linked... yes
checking if freeaddrinfo is prototyped... yes
checking if freeaddrinfo is compilable... yes
checking if freeaddrinfo usage allowed... yes
checking if freeaddrinfo might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for ifaddrs.h... yes
checking if freeifaddrs can be linked... yes
checking if freeifaddrs is prototyped... yes
checking if freeifaddrs is compilable... yes
checking if freeifaddrs usage allowed... yes
checking if freeifaddrs might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/xattr.h... yes
checking if fsetxattr can be linked... yes
checking if fsetxattr is prototyped... yes
checking if fsetxattr takes 5 args.... yes
checking if fsetxattr is compilable... yes
checking if fsetxattr usage allowed... yes
checking if fsetxattr might be used... yes
checking if ftruncate can be linked... yes
checking if ftruncate is prototyped... yes
checking if ftruncate is compilable... yes
checking if ftruncate usage allowed... yes
checking if ftruncate might be used... yes
checking for sys/types.h... (cached) yes
checking for stdlib.h... (cached) yes
checking if getaddrinfo can be linked... yes
checking if getaddrinfo is prototyped... yes
checking if getaddrinfo is compilable... yes
checking if getaddrinfo seems to work... yes
checking if getaddrinfo usage allowed... yes
checking if getaddrinfo might be used... yes
checking if getaddrinfo is threadsafe... yes
checking if gai_strerror can be linked... yes
checking if gai_strerror is prototyped... yes
checking if gai_strerror is compilable... yes
checking if gai_strerror usage allowed... yes
checking if gai_strerror might be used... yes
checking if gethostbyaddr can be linked... yes
checking if gethostbyaddr is prototyped... yes
checking if gethostbyaddr is compilable... yes
checking if gethostbyaddr usage allowed... yes
checking if gethostbyaddr might be used... yes
checking if gethostbyaddr_r can be linked... yes
checking if gethostbyaddr_r is prototyped... yes
checking if gethostbyaddr_r takes 5 args.... no
checking if gethostbyaddr_r takes 7 args.... no
checking if gethostbyaddr_r takes 8 args.... yes
checking if gethostbyaddr_r is compilable... yes
checking if gethostbyaddr_r usage allowed... yes
checking if gethostbyaddr_r might be used... yes
checking if gethostbyname can be linked... yes
checking if gethostbyname is prototyped... yes
checking if gethostbyname is compilable... yes
checking if gethostbyname usage allowed... yes
checking if gethostbyname might be used... yes
checking if gethostbyname_r can be linked... yes
checking if gethostbyname_r is prototyped... yes
checking if gethostbyname_r takes 3 args.... no
checking if gethostbyname_r takes 5 args.... no
checking if gethostbyname_r takes 6 args.... yes
checking if gethostbyname_r is compilable... yes
checking if gethostbyname_r usage allowed... yes
checking if gethostbyname_r might be used... yes
checking if gethostname can be linked... yes
checking if gethostname is prototyped... yes
checking if gethostname is compilable... yes
checking for gethostname arg 2 data type... size_t
checking if gethostname usage allowed... yes
checking if gethostname might be used... yes
checking if getifaddrs can be linked... yes
checking if getifaddrs is prototyped... yes
checking if getifaddrs is compilable... yes
checking if getifaddrs seems to work... yes
checking if getifaddrs usage allowed... yes
checking if getifaddrs might be used... yes
checking if getservbyport_r can be linked... yes
checking if getservbyport_r is prototyped... yes
checking if getservbyport_r takes 4 args.... no
checking if getservbyport_r takes 5 args.... no
checking if getservbyport_r takes 6 args.... yes
checking if getservbyport_r is compilable... yes
checking if getservbyport_r usage allowed... yes
checking if getservbyport_r might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for time.h... (cached) yes
checking if gmtime_r can be linked... yes
checking if gmtime_r is prototyped... yes
checking if gmtime_r is compilable... yes
checking if gmtime_r seems to work... yes
checking if gmtime_r usage allowed... yes
checking if gmtime_r might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking if inet_ntoa_r can be linked... no
checking if inet_ntoa_r might be used... no
checking if inet_ntop can be linked... yes
checking if inet_ntop is prototyped... yes
checking if inet_ntop is compilable... yes
checking if inet_ntop seems to work... yes
checking if inet_ntop usage allowed... yes
checking if inet_ntop might be used... yes
checking if inet_pton can be linked... yes
checking if inet_pton is prototyped... yes
checking if inet_pton is compilable... yes
checking if inet_pton seems to work... yes
checking if inet_pton usage allowed... yes
checking if inet_pton might be used... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for sys/ioctl.h... (cached) yes
checking for stropts.h... yes
checking if ioctl can be linked... yes
checking if ioctl is prototyped... yes
checking if ioctl is compilable... yes
checking if ioctl usage allowed... yes
checking if ioctl might be used... yes
checking if ioctl FIONBIO is compilable... yes
checking if ioctl FIONBIO usage allowed... yes
checking if ioctl FIONBIO might be used... yes
checking if ioctl SIOCGIFADDR is compilable... yes
checking if ioctl SIOCGIFADDR usage allowed... yes
checking if ioctl SIOCGIFADDR might be used... yes
checking if ioctlsocket can be linked... no
checking if ioctlsocket might be used... no
checking if IoctlSocket can be linked... no
checking if IoctlSocket might be used... no
checking if localtime_r can be linked... yes
checking if localtime_r is prototyped... yes
checking if localtime_r is compilable... yes
checking if localtime_r seems to work... yes
checking if localtime_r usage allowed... yes
checking if localtime_r might be used... yes
checking if memrchr can be linked... yes
checking if memrchr is prototyped... no
checking if memrchr might be used... no
checking if poll can be linked... yes
checking if poll is prototyped... yes
checking if poll is compilable... yes
checking if poll seems to work... yes
checking if poll usage allowed... yes
checking if poll might be used... yes
checking if setsockopt can be linked... yes
checking if setsockopt is prototyped... yes
checking if setsockopt is compilable... yes
checking if setsockopt usage allowed... yes
checking if setsockopt might be used... yes
checking if setsockopt SO_NONBLOCK is compilable... no
checking if setsockopt SO_NONBLOCK might be used... no
checking for sys/types.h... (cached) yes
checking for signal.h... (cached) yes
checking if sigaction can be linked... yes
checking if sigaction is prototyped... yes
checking if sigaction is compilable... yes
checking if sigaction usage allowed... yes
checking if sigaction might be used... yes
checking if siginterrupt can be linked... yes
checking if siginterrupt is prototyped... yes
checking if siginterrupt is compilable... yes
checking if siginterrupt usage allowed... yes
checking if siginterrupt might be used... yes
checking if signal can be linked... yes
checking if signal is prototyped... yes
checking if signal is compilable... yes
checking if signal usage allowed... yes
checking if signal might be used... yes
checking for sys/types.h... (cached) yes
checking for setjmp.h... (cached) yes
checking if sigsetjmp can be linked... no
checking if sigsetjmp seems a macro... yes
checking if sigsetjmp is compilable... yes
checking if sigsetjmp usage allowed... yes
checking if sigsetjmp might be used... yes
checking if socket can be linked... yes
checking if socket is prototyped... yes
checking if socket is compilable... yes
checking if socket usage allowed... yes
checking if socket might be used... yes
checking if socketpair can be linked... yes
checking if socketpair is prototyped... yes
checking if socketpair is compilable... yes
checking if socketpair usage allowed... yes
checking if socketpair might be used... yes
checking if strcasecmp can be linked... yes
checking if strcasecmp is prototyped... yes
checking if strcasecmp is compilable... yes
checking if strcasecmp usage allowed... yes
checking if strcasecmp might be used... yes
checking if strcmpi can be linked... no
checking if strcmpi might be used... no
checking if strdup can be linked... yes
checking if strdup is prototyped... yes
checking if strdup is compilable... yes
checking if strdup usage allowed... yes
checking if strdup might be used... yes
checking if strerror_r can be linked... yes
checking if strerror_r is prototyped... yes
checking if strerror_r is compilable... yes
checking if strerror_r is glibc like... no
checking if strerror_r is POSIX like... yes
checking if strerror_r seems to work... yes
checking if strerror_r usage allowed... yes
checking if strerror_r might be used... yes
checking if stricmp can be linked... no
checking if stricmp might be used... no
checking if strncasecmp can be linked... yes
checking if strncasecmp is prototyped... yes
checking if strncasecmp is compilable... yes
checking if strncasecmp usage allowed... yes
checking if strncasecmp might be used... yes
checking if strncmpi can be linked... no
checking if strncmpi might be used... no
checking if strnicmp can be linked... no
checking if strnicmp might be used... no
checking if strstr can be linked... yes
checking if strstr is prototyped... yes
checking if strstr is compilable... yes
checking if strstr usage allowed... yes
checking if strstr might be used... yes
checking if strtok_r can be linked... yes
checking if strtok_r is prototyped... yes
checking if strtok_r is compilable... yes
checking if strtok_r usage allowed... yes
checking if strtok_r might be used... yes
checking if strtoll can be linked... yes
checking if strtoll is prototyped... yes
checking if strtoll is compilable... yes
checking if strtoll usage allowed... yes
checking if strtoll might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/uio.h... (cached) yes
checking if writev can be linked... yes
checking if writev is prototyped... yes
checking if writev is compilable... yes
checking if writev usage allowed... yes
checking if writev might be used... yes
checking for fork... yes
checking for geteuid... yes
checking for getpass_r... no
checking deeper for getpass_r... but still no
checking for getppid... yes
checking for getprotobyname... yes
checking for getpwuid... yes
checking for getpwuid_r... yes
checking for getrlimit... yes
checking for gettimeofday... yes
checking for if_nametoindex... yes
checking for inet_addr... yes
checking for perror... yes
checking for pipe... yes
checking for setlocale... yes
checking for setmode... no
checking deeper for setmode... but still no
checking for setrlimit... yes
checking for uname... yes
checking for utime... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netdb.h... (cached) yes
checking for getnameinfo... yes
checking types of arguments for getnameinfo... const struct sockaddr *,socklen_t,socklen_t,int
checking for stdio.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netdb.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking for working NI_WITHSCOPEID... no
checking how to set a socket into non-blocking mode... fcntl O_NONBLOCK
checking for perl... /usr/bin/perl
checking for gnroff... no
checking for nroff... no
checking whether to enable the threaded resolver... no
checking whether to enable verbose strings... yes
checking whether to enable SSPI support (Windows native builds only)... no
checking whether to enable cryptographic authentication methods... yes
checking whether to enable NTLM delegation to winbind's helper... yes
checking whether to enable TLS-SRP authentication... yes
checking whether to enable support for cookies... yes
checking whether hiding of library internal symbols will actually happen... yes
checking whether to enforce SONAME bump... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating docs/Makefile
config.status: creating docs/examples/Makefile
config.status: creating docs/libcurl/Makefile
config.status: creating docs/libcurl/opts/Makefile
config.status: creating include/Makefile
config.status: creating include/curl/Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating lib/libcurl.vers
config.status: creating tests/Makefile
config.status: creating tests/certs/Makefile
config.status: creating tests/certs/scripts/Makefile
config.status: creating tests/data/Makefile
config.status: creating tests/server/Makefile
config.status: creating tests/libtest/Makefile
config.status: creating tests/unit/Makefile
config.status: creating packages/Makefile
config.status: creating packages/Win32/Makefile
config.status: creating packages/Win32/cygwin/Makefile
config.status: creating packages/Linux/Makefile
config.status: creating packages/Linux/RPM/Makefile
config.status: creating packages/Linux/RPM/curl.spec
config.status: creating packages/Linux/RPM/curl-ssl.spec
config.status: creating packages/Solaris/Makefile
config.status: creating packages/EPM/curl.list
config.status: creating packages/EPM/Makefile
config.status: creating packages/vms/Makefile
config.status: creating packages/AIX/Makefile
config.status: creating packages/AIX/RPM/Makefile
config.status: creating packages/AIX/RPM/curl.spec
config.status: creating curl-config
config.status: creating libcurl.pc
config.status: creating lib/curl_config.h
config.status: lib/curl_config.h is unchanged
config.status: creating include/curl/curlbuild.h
config.status: include/curl/curlbuild.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
configure: Configured to build curl/libcurl:

  curl version:     7.39.1-DEV
  Host setup:       x86_64-unknown-linux-gnu
  Install prefix:   /source/target/debug/build/curl-sys-19ec055fea136d2a/out
  Compiler:         gcc
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  enabled
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  ipv6 support:     enabled
  IDN support:      no      (--with-{libidn,winidn})
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  no      (--enable-manual)
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     no
  LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS support:    no      (--enable-ldaps)
  RTSP support:     no      (--enable-rtsp)
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        FILE HTTP HTTPS

running: "make" "-j4"

--- stderr
configure: WARNING: disabling built-in manual
thread '<main>' panicked at 'cmd.status() return the error No such file or directory (os error 2)', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-sys-0.1.20/build.rs:128

Unnecessary string allocation

This diff can be applied if the dependency requirement for rust-url is tightened to 1.0+. See #103.

diff --git a/src/http/handle.rs b/src/http/handle.rs
index ac3b8b0..5d1e2d4 100644
--- a/src/http/handle.rs
+++ b/src/http/handle.rs
@@ -426,7 +426,7 @@ impl<'a> ToUrl for &'a str {
 impl<'a> ToUrl for &'a Url {
     fn with_url_str<F>(self, f: F) where F: FnOnce(&str) {
-        self.to_string().with_url_str(f);
+        self.as_str().with_url_str(f);
     }
 }

32-bit armv7 build fails

I think it's part of some systemic breakage (libc?) as I had already seen this error before: jeaye/ncurses-rs#99

Compiling curl v0.2.13
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/err.rs:120:28: 120:64 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/err.rs:120             CStr::from_ptr(ffi::curl_easy_strerror(self.code())).to_bytes()
                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/err.rs:120:28: 120:64 help: run `rustc --explain E0308` to see a detailed explanation
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:203:39: 203:40 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:203         str::from_utf8(CStr::from_ptr(p).to_bytes()).ok()
                                                                                                                                      ^
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:203:39: 203:40 help: run `rustc --explain E0308` to see a detailed explanation
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:215:39: 215:58 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:215         str::from_utf8(CStr::from_ptr(ffi::curl_version()).to_bytes()).unwrap()
                                                                                                                                      ^~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-0.2.13/src/ffi/version.rs:215:39: 215:58 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to 3 previous errors

Built with rustc 1.6.0-dev (d53496bda 2015-11-06)

My guess about the libc crate was probably right:
https://users.rust-lang.org/t/the-libc-crate-is-now-at-v0-2-0/3509/5

#[derive(Debug)] for Request

I just played with a REST API and had to fire up Wireshark in order to see what the request looked like in detail (including headers). It would be far easier to see whats going on if Debug was implemented for Request.

Otherwise, great crate!
Phil

Use of openssl-sys is problematic

  1. curl-sys/build.rs (in some cases) uses pkg-config, which will already pull in the correct ssl library for that particular compilation of curl.
  2. curl-sys includes openssl-sys as an extern crate and proceeds to never use it
  3. For non-blessed targets, using target-specific dependencies to pull in openssl-sys breaks the build of curl-rust as it actually uses the openssl crate.

Some of these are probably due to a mismatch in cargo between the way linking actually works and how it currently pretends it works (ie: trys to avoid adding duplicate native libraries in the linker command line where this is actually the norm).

Fail to build on Windows: The system cannot find the file specified

After adding to Cargo.toml the curl dependency. On building:

   Compiling curl-sys v0.1.22
failed to run custom build command for `curl-sys v0.1.22`
Process didn't exit successfully: `D:\Code\projects\badgerGP\target\debug\build\curl-sys-dd89af55ea8cd7e5\build-script-build` (exit code: 101)
--- stdout
running: "sh" "-c" "/c/Users/MB/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-sys-0.1.22/curl/configure --with-winssl --enable-static=yes --enable-shared=no --enable-optimize --prefix=D:/Code/projects/badgerGP/target/debug/build/curl-sys-dd89af55ea8cd7e5/out --without-librtmp --without-libidn --without-libssh2 --without-nghttp2 --disable-ldap --disable-ldaps --disable-ftp --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual"

--- stderr
thread '<main>' panicked at 'cmd.status() return the error The system cannot find the file specified.
 (os error 2)', C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\curl-sys-0.1.22\build.rs:128

Can't build on Windows

   Compiling curl-sys v0.1.5
Build failed, waiting for other jobs to finish...
failed to run custom build command for `curl-sys v0.1.5`
Process didn't exit successfully: `C:\GitHub\mtg-rust\target\build\curl-sys-c3e3bf354b130c95\build-script-build.exe` (status=101)
--- stderr
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libcore\option.rs:361


Compilation exited abnormally with code 101 at Mon Jan 26 15:17:55

Test instability - Errant Connections closed during tests

I ran

export BROKE=true;while $BROKE; do cargo test test_post::test_post_binary_with_reader || BROKE=false ;done

in a couple of terminals. It got the following errors (after a bunch of tries)

running 2 tests
*** Error in /home/posix4e/projects/curl-rust/target/debug/test-33ef6bd56fa132ca': double free or corruption (fasttop): 0x00007ff64000cd30 *** Process didn't exit successfully:/home/posix4e/projects/curl-rust/target/debug/test-33ef6bd56fa132ca test_post::test_post_binary_with_reader` (signal: 6)
posix4e@posix4e-P27GV2:/projects/curl-rust$ ^C
posix4e@posix4e-P27GV2:
/projects/curl-rust$ export BROKE=true;while $BROKE; do cargo test test_post::test_post_binary_with_reader || BROKE=false ;done

or
running 2 tests
test test_post::test_post_binary_with_reader ... FAILED
test test_post::test_post_binary_with_reader_and_content_length ... ok

failures:

---- test_post::test_post_binary_with_reader stdout ----
thread 'test_post::test_post_binary_with_reader' panicked at 'called Result::unwrap() on an Err value: Failed sending data to the peer', src/libcore/result.rs:731

Iterators are not generic anymore

When building with freshly built rustc, errors are reported like the one below:

/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-0.1.5/src/ffi/version.rs:156:10: 156:27 error: wrong number of type arguments: expected 0, found 1
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-0.1.5/src/ffi/version.rs:156 impl<'a> Iterator<&'a str> for Protocols<'a> {

Can't build dylib

I'd like to build curl-rust as dylib (more precisely as shared object *.so).
I added 'crate type' to Cargo.toml and tried to build:

$ git diff
diff --git a/Cargo.toml b/Cargo.toml
index 95621a5..7122360 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,9 @@ log = "0.3.0"
 libc = "0.2"
 curl-sys = { path = "curl-sys", version = "0.1.0" }

+[lib]
+crate-type = ["rlib", "dylib"]
+
 [dev-dependencies]
 env_logger = "0.3.0"
$ cargo build --release
   Compiling pkg-config v0.3.6
   Compiling libc v0.2.2
   Compiling gcc v0.3.19
   Compiling matches v0.1.2
   Compiling rustc-serialize v0.3.16
   Compiling libc v0.1.12
   Compiling log v0.3.3
   Compiling libz-sys v0.1.9
   Compiling curl-sys v0.1.27 (file:///home/aarbuzov/git/curl-rust)
   Compiling openssl-sys v0.6.7
   Compiling url v0.2.37
   Compiling curl v0.2.13 (file:///home/aarbuzov/git/curl-rust)
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-m64" "-L" "/home/aarbuzov/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/aarbuzov/git/curl-rust/target/release/curl.0.o" "-o" "/home/aarbuzov/git/curl-rust/target/release/libcurl.so" "/home/aarbuzov/git/curl-rust/target/release/curl.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/aarbuzov/git/curl-rust/target/release" "-L" "/home/aarbuzov/git/curl-rust/target/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/home/aarbuzov/git/curl-rust/target/release/build/openssl-sys-f0bee5fb97afc90d/out" "-L" "/home/aarbuzov/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/aarbuzov/git/curl-rust/.rust/lib/x86_64-unknown-linux-gnu" "-L" "/home/aarbuzov/git/curl-rust/lib/x86_64-unknown-linux-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liburl-5247f81b4a7b5841.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/librustc_serialize-7ff5bfc027146194.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liblog-35171053ffe7ab96.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libcurl_sys-0d38319d29f4714a.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libopenssl_sys-f0bee5fb97afc90d.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liblibc-540159808ccfa9ab.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libmatches-68291f81832fc22d.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liblibz_sys-3753452b802ce1b9.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liblibc-29adb837ec836726.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libstd-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libcollections-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/librustc_unicode-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/librand-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liballoc-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liballoc_system-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/liblibc-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.3AlOKJZLKvC6/libcore-8cf6ce90.rlib" "-Wl,--no-whole-archive" "-l" "curl" "-l" "ssl" "-l" "crypto" "-l" "z" "-l" "c" "-l" "m" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "rt" "-l" "pthread" "-l" "c" "-l" "m" "-shared" "-Wl,-rpath,$ORIGIN/../../../../.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "compiler-rt"
note: /home/aarbuzov/git/curl-rust/target/release/libcurl.so: file not recognized: File truncated
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `curl`.

To learn more, run the command again with --verbose.

What I did wrong? Is it possible to build curl-rust as so-lib ?

Thanks.

Built failed in ubuntu 14.04 with rust version 1.6 nightly

configure: Configured to build curl/libcurl:

curl version: 7.39.1-DEV
Host setup: x86_64-unknown-linux-gnu
Install prefix: /srv/cm-api/target/debug/build/curl-sys-7b8575484fdded56/out
Compiler: cc
SSL support: enabled (OpenSSL)
SSH support: no (--with-libssh2)
zlib support: enabled
GSS-API support: no (--with-gssapi)
TLS-SRP support: enabled
resolver: default (--enable-ares / --enable-threaded-resolver)
ipv6 support: enabled
IDN support: no (--with-{libidn,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: no (--enable-manual)
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: no
ca cert path: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: no (--enable-rtsp)
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
HTTP2 support: disabled (--with-nghttp2)
Protocols: FILE HTTP HTTPS

running: "make" "-j2"

--- stderr
thread '

' panicked at 'cmd.status() return the error No such file or directory (os error 2)', /home/ubuntu/.cargo/registry/src/github.com-88ac128001ac3a9a/curl-sys-0.1.29/build.rs:130

Cannot compile: No method 'join'

I'm compiling my project using the nightly Rust build and have encountered the following error when trying to compile curl-rust:

build.rs:92:43: 92:65 error: type `core::result::Result<std::path::posix::Path, std::io::IoError>` does not implement any method in scope named `join`
build.rs:92                 .arg(format!("{} {}", src.join("curl/configure").display(),
                                                      ^~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Haven't been able to find any info on this, is it possible that something in the core library changed?

Build fail on Windows with gcc ver. 0.3.30

crate gcc are updated to 0.3.30 on Jul 13, 2016.
When I compil on Windows 10, I got this error :

Compiling curl-sys v0.2.0
error: failed to run custom build command for curl-sys v0.2.0
Process didn't exit successfully: C:\Users\RUST Project\htmlparser\target\release\build\curl-sys-81c7fcebd44133fa\build-script-build (exit code: 101)

"cargo build --release" completed with code 101

I update to gcc Ver. 0.3.28 in cargo.toml like this :

[dependencies]
curl = "*"
gcc = "= 0.3.28"

It's work fine.

[v0.2.19] unresolved import `curl::easy::Easy`. Could not find `easy` in `curl`

Compiling any of the examples does not work for me.

Build output

cargo build --verbose

       Fresh libc v0.2.11
       Fresh matches v0.1.2
       Fresh rustc-serialize v0.3.19
       Fresh pkg-config v0.3.8
       Fresh gcc v0.3.28
       Fresh unicode-normalization v0.1.2
       Fresh log v0.3.6
       Fresh unicode-bidi v0.2.3
       Fresh toml v0.1.30
       Fresh idna v0.1.0
       Fresh url v1.1.0
       Fresh openssl-sys v0.7.12
       Fresh libz-sys v1.0.3
       Fresh curl-sys v0.1.34
       Fresh curl v0.2.19
   Compiling saml_md_processor v0.1.0 (file:///home/sanmai/devel/Rust/saml_md_processor)
     Running `rustc src/main.rs --crate-name saml_md_processor --crate-type bin -g --out-dir /home/sanmai/devel/Rust/saml_md_processor/target/debug --emit=dep-info,link -L dependency=/home/sanmai/devel/Rust/saml_md_processor/target/debug -L dependency=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps --extern toml=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps/libtoml-cd71fbce840828ea.rlib --extern curl=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps/libcurl-f9ef0f2f3d025736.rlib -L native=/usr/lib -L native=/usr/lib -L native=/usr/lib`
src/main.rs:3:5: 3:21 error: unresolved import `curl::easy::Easy`. Could not find `easy` in `curl` [E0432]
src/main.rs:3 use curl::easy::Easy;
                  ^~~~~~~~~~~~~~~~
src/main.rs:3:5: 3:21 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:8:5: 8:43 error: the type of this value must be known in this context
src/main.rs:8     easy.url("https://www.rust-lang.org/").unwrap();
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
error: Could not compile `saml_md_processor`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name saml_md_processor --crate-type bin -g --out-dir /home/sanmai/devel/Rust/saml_md_processor/target/debug --emit=dep-info,link -L dependency=/home/sanmai/devel/Rust/saml_md_processor/target/debug -L dependency=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps --extern toml=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps/libtoml-cd71fbce840828ea.rlib --extern curl=/home/sanmai/devel/Rust/saml_md_processor/target/debug/deps/libcurl-f9ef0f2f3d025736.rlib -L native=/usr/lib -L native=/usr/lib -L native=/usr/lib` (exit code: 101)

Meta

curl

curl-config --configure --cc --libs --version

 '--prefix=/usr' '--mandir=/usr/share/man' '--disable-ldap' '--disable-ldaps' '--enable-ipv6' '--enable-manual' '--enable-versioned-symbols' '--enable-threaded-resolver' '--with-gssapi' '--with-libidn' '--with-random=/dev/urandom' '--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt' 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -g -fvar-tracking-assignments' 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2'
gcc
-lcurl
libcurl 7.48.0

Rust

rustc --version --verbose

rustc 1.8.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.8.0

Call to `str::from_c_str` gets `*const libc::c_char` but it always expects `*const i8`, which may not always be the case

When building for an architecture where libc::c_char is not i8 (e.g., for AArch64 where it is u8), we get an error like this:

src/ffi/err.rs:127:34: 127:63 error: mismatched types: expected `*const i8`, found `*const u8` (expected i8, found u8)

It seems that it has to be fixed at the caller's side (i.e., in curl-rust), since str::from_c_str is part of libcore, which is declared as dependency-free, so str::from_c_str cannot be changed to expect *const libc::c_char. IMHO.

This issue is identical to https://github.com/alexcrichton/git2-rs/issues/30

Use of 'strtok_r' fails in Windows

I come across this error when trying to compile on Windows. I have MSYS2 installed (I used the rust guide that is linked in the tutorial). It seems that 'strtok_r' is not supported by MSYS2.

error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\hello_world.0.o" "-o" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\hello_world.exe" "-Wl,--gc-sections" "-L" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug" "-L" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps" "-L" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\build\\curl-sys-c7834bee3e6a49e1\\out/lib" "-L" "C:/msys64/mingw64/lib" "-L" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\.rust\\bin\\x86_64-pc-windows-gnu" "-L" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\bin\\x86_64-pc-windows-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libcurl-cc078f6df50d4b80.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\liburl-9145034d63069ffd.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\liblog-db195e915b7f1b50.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libcurl_sys-c7834bee3e6a49e1.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libuuid-82ee95c4f525f1f6.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\librustc_serialize-7ff5bfc027146194.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libmatches-68291f81832fc22d.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\librand-204b49f864ff4762.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libadvapi32-cfef7a1f30f1e5f6.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\libwinapi-d88a8c018c340227.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\liblibz_sys-521f51dd8fade4c2.rlib" "C:\\Users\\User\\Documents\\eclipse\\workspace\\test\\target\\debug\\deps\\liblibc-53b3109cf33a6ace.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_unicode-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_jemalloc-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-35c36e89.rlib" "C:\\Program Files\\Rust stable 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-35c36e89.rlib" "-l" "ws2_32" "-l" "advapi32" "-l" "z" "-l" "ws2_32" "-l" "userenv" "-l" "advapi32" "-l" "compiler-rt"
note: C:\Users\User\Documents\eclipse\workspace\test\target\debug\deps\libcurl_sys-c7834bee3e6a49e1.rlib(libcurl_la-cookie.o):cookie.c:(.text$Curl_cookie_add+0xc5): undefined reference to `strtok_r'
C:\Users\User\Documents\eclipse\workspace\test\target\debug\deps\libcurl_sys-c7834bee3e6a49e1.rlib(libcurl_la-cookie.o):cookie.c:(.text$Curl_cookie_add+0x13a): undefined reference to `strtok_r'
ld: C:\Users\User\Documents\eclipse\workspace\test\target\debug\deps\libcurl_sys-c7834bee3e6a49e1.rlib(libcurl_la-cookie.o): bad reloc address 0x13a in section `.text$Curl_cookie_add'
ld: final link failed: Invalid operation

Could there be something I missed in my install?
I cannot find much about this error online except that this function is not on Windows.

Unable to get packages from source

At some point, there is invalid input:

$ git clone https://github.com/carllerche/curl-rust/
$ cd curl-rust
$ cargo build --verbose
Unable to get packages from source

Caused by:
  Failed to unpack package `curl-sys v0.1.0`

Caused by:
  invalid input

Segmentation fault on incorrect use of Transfer

So I'm a new to Rust in general and was playing around with curl-rust when I got a segfault on calling the following function:

fn get_page(session: Box<IoFuture<Session>>) -> Box<Future<Item = String, Error = std::io::Error>> {

    session.and_then(|sess| {
        // Prepare the HTTP request to be sent.
        let mut req = Easy::new();
        req.get(true).unwrap();
        req.url("https://www.rust-lang.org").unwrap();

        req.transfer()
            .write_function(|data| {
                Ok(data.len())
            })
            .unwrap();

        sess.perform(req).map(|_e| "blah".to_owned())
    })
        .boxed()
}

I'm pretty sure it results from an incorrect usage of Transfer but the code shouldn't even compile.. memory safety is being violated somewhere.

Further investigation using gdb revealed that the culprit is:

Thread 1 "demo" received signal SIGSEGV, Segmentation fault.
0x00005555555e7ea2 in curl::easy::transfer_write_cb::{{closure}}::{{closure}} (
    f=0x7ffff4ac7000)
    at /home/random/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-0.3.3/src/easy.rs:2761
2761            (*(data as *mut TransferData)).write.as_mut().map(|f| f(buf))

Oh and it would be great if someone could suggest me a way to accomplish what I want (return the webpage retrieved as a Future that returns String) using the futures crate.

The first example on the README.md doesn't work.

extern crate curl;

use curl::http;

pub fn main() {
  let resp = http::handle()
    .get("http://www.example.com")
    .exec().unwrap();

  println!("code={}; headers={}; body={}",
    resp.get_code(), resp.get_headers(), resp.get_body());
}

Returns the error:

/home/fag/code/rust/curltest/src/main.rs:11:22: 11:40 error: the trait `core::fmt::String` is not implemented for the type `std::collections::hash::map::HashMap<collections::string::String, collections::vec::Vec<collections::string::String>>`
/home/fag/code/rust/curltest/src/main.rs:11     resp.get_code(), resp.get_headers(), resp.get_body());
                                                                 ^~~~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:42: 2:75 note: expansion site
<std macros>:1:1: 2:77 note: in expansion of println!
/home/fag/code/rust/curltest/src/main.rs:10:3: 11:59 note: expansion site
/home/fag/code/rust/curltest/src/main.rs:11:42: 11:57 error: the trait `core::fmt::String` is not implemented for the type `[u8]`
/home/fag/code/rust/curltest/src/main.rs:11     resp.get_code(), resp.get_headers(), resp.get_body());
                                                                                     ^~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:42: 2:75 note: expansion site
<std macros>:1:1: 2:77 note: in expansion of println!
/home/fag/code/rust/curltest/src/main.rs:10:3: 11:59 note: expansion site
error: aborting due to 2 previous errors
Could not compile `curltest`.

Nevermind, I'm a retard.

Failed to cross-compile the example program from x86_64 Linux

I built a Rust 1.2.0 compiler under Fedora (x86_64) which supported multiple targets including x86_64-pc-windows-gnu and arm-unknown-linux-gnueabihf and successfully compiled some simple programs.

However, I failed to cross-compile the example program from curl-rust. (I can compile the example directly under Windows, haven't tried under ARM.)

When building for x86_64-pc-windows-gnu, I got:

     Compiling curl_example v0.1.0 (file:///home/frederick/rust/curl_example)
     Running `rustc src/main.rs --crate-name curl_example --crate-type bin -C opt-level=3 --out-dir /home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release --emit=dep-info,link --target x86_64-pc-windows-gnu -C ar=x86_64-w64-mingw32-ar -C linker=x86_64-w64-mingw32-gcc -L dependency=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release -L dependency=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps --extern curl=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libcurl-8828a61714ae0eb4.rlib -L /home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/build/curl-sys-b582fd2220a1331e/out/lib`
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
note: "x86_64-w64-mingw32-gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/curl_example.o" "-o" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/curl_example.exe" "-Wl,--gc-sections" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libcurl-8828a61714ae0eb4.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libcurl_sys-b582fd2220a1331e.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/liburl-5247f81b4a7b5841.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libmatches-68291f81832fc22d.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/liblog-8a6aba167994951e.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/liblibz_sys-e8e1552876cd3abe.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/liblibc-144c435538abd757.rlib" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/librustc_serialize-7ff5bfc027146194.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/libcollections-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_unicode-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/librand-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-d8ace771.rlib" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-d8ace771.rlib" "-L" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release" "-L" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps" "-L" "/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/build/curl-sys-b582fd2220a1331e/out/lib" "-L" "/usr/local/lib/rustlib/x86_64-pc-windows-gnu/lib" "-L" "/home/frederick/rust/curl_example/.rust/lib/x86_64-pc-windows-gnu" "-L" "/home/frederick/rust/curl_example/lib/x86_64-pc-windows-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "ws2_32" "-l" "z" "-l" "ws2_32" "-l" "userenv" "-l" "advapi32" "-l" "compiler-rt"
note: /home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libcurl_sys-b582fd2220a1331e.rlib(r-curl-libcurl_la-version.o): could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `curl_example`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name curl_example --crate-type bin -C opt-level=3 --out-dir /home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release --emit=dep-info,link --target x86_64-pc-windows-gnu -C ar=x86_64-w64-mingw32-ar -C linker=x86_64-w64-mingw32-gcc -L dependency=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release -L dependency=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps --extern curl=/home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/deps/libcurl-8828a61714ae0eb4.rlib -L /home/frederick/rust/curl_example/target/x86_64-pc-windows-gnu/release/build/curl-sys-b582fd2220a1331e/out/lib` (exit code: 101)

When building for arm-unknown-linux-gnueabihf, I got:

   Compiling curl_example v0.1.0 (file:///home/frederick/rust/curl_example)
     Running `rustc src/main.rs --crate-name curl_example --crate-type bin -C opt-level=3 --out-dir /home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release --emit=dep-info,link --target arm-unknown-linux-gnueabihf -C ar=arm-linux-gnueabihf-ar -C linker=arm-linux-gnueabihf-gcc -L dependency=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release -L dependency=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps --extern curl=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib -L /home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/curl-sys-b582fd2220a1331e/out/lib -L native=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/openssl-sys-765ddf9de3c5179c/out`
error: linking with `arm-linux-gnueabihf-gcc` failed: exit code: 1
note: "arm-linux-gnueabihf-gcc" "-Wl,--as-needed" "-L" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/curl_example.o" "-o" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/curl_example" "-Wl,--whole-archive" "-l" "morestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl_sys-b582fd2220a1331e.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/liburl-5247f81b4a7b5841.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libmatches-68291f81832fc22d.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/liblog-8a6aba167994951e.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/liblibz_sys-e8e1552876cd3abe.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/librustc_serialize-7ff5bfc027146194.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libopenssl_sys-765ddf9de3c5179c.rlib" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/liblibc-144c435538abd757.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcollections-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_unicode-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librand-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liblibc-d8ace771.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcore-d8ace771.rlib" "-L" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release" "-L" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps" "-L" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/curl-sys-b582fd2220a1331e/out/lib" "-L" "/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/openssl-sys-765ddf9de3c5179c/out" "-L" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-L" "/home/frederick/rust/curl_example/.rust/lib/arm-unknown-linux-gnueabihf" "-L" "/home/frederick/rust/curl_example/lib/arm-unknown-linux-gnueabihf" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "z" "-l" "crypto" "-l" "ssl" "-l" "c" "-l" "m" "-l" "dl" "-l" "pthread" "-l" "rt" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: /home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/curl_example.o: In function `main::h3f0c65dd085aa280gaa':
curl_example.0.rs:(.text._ZN4main20h3f0c65dd085aa280gaaE+0x188): undefined reference to `curl_easy_setopt'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `ffi::easy::global_init::cleanup::hfb9c781cea2b575dzia':
curl.0.rs:(.text._ZN3ffi4easy11global_init7cleanup20hfb9c781cea2b575dziaE+0x0): undefined reference to `curl_global_cleanup'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `ffi::easy::Easy.Drop::drop::h0c646593d425c9d3Hia':
curl.0.rs:(.text._ZN3ffi4easy9Easy.Drop4drop20h0c646593d425c9d3HiaE+0x4): undefined reference to `curl_easy_cleanup'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `ffi::err::ErrCode.fmt..Display::fmt::h032b81c4990a5e2fOra':
curl.0.rs:(.text._ZN3ffi3err20ErrCode.fmt..Display3fmt20h032b81c4990a5e2fOraE+0x48): undefined reference to `curl_easy_strerror'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `http::handle::Handle::new::hcbd4647fea69f7fe3Va':
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x220): undefined reference to `curl_easy_init'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x230): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x244): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x260): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x49c): undefined reference to `curl_easy_cleanup'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x534): undefined reference to `curl_easy_cleanup'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x558): undefined reference to `curl_easy_cleanup'
curl.0.rs:(.text._ZN4http6handle6Handle3new20hcbd4647fea69f7fe3VaE+0x5dc): undefined reference to `curl_easy_cleanup'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `ffi::easy::Easy::setopt::h17415893674049649907':
curl.0.rs:(.text._ZN3ffi4easy4Easy6setopt21h17415893674049649907E+0x1bc): undefined reference to `curl_easy_setopt'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `http::handle::Request$LT$$u27$a$C$$u20$$u27$b$GT$::exec::hd3fad3894ea8584cgab':
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x108): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x14c): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x1a0): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x1b8): undefined reference to `curl_easy_setopt'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o):curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x1d0): more undefined references to `curl_easy_setopt' follow
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `http::handle::Request$LT$$u27$a$C$$u20$$u27$b$GT$::exec::hd3fad3894ea8584cgab':
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x8e4): undefined reference to `curl_slist_append'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x94c): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0x998): undefined reference to `curl_slist_free_all'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xa30): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xa50): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xa70): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xa84): undefined reference to `curl_easy_setopt'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xaa4): undefined reference to `curl_easy_setopt'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o):curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xabc): more undefined references to `curl_easy_setopt' follow
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `http::handle::Request$LT$$u27$a$C$$u20$$u27$b$GT$::exec::hd3fad3894ea8584cgab':
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xaf8): undefined reference to `curl_easy_perform'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xb30): undefined reference to `curl_easy_getinfo'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xc0c): undefined reference to `curl_slist_free_all'
curl.0.rs:(.text._ZN4http6handle35Request$LT$$u27$a$C$$u20$$u27$b$GT$4exec20hd3fad3894ea8584cgabE+0xe24): undefined reference to `curl_slist_free_all'
/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib(curl-8828a61714ae0eb4.o): In function `ffi::easy::Easy::setopt::h1335928551378549339':
curl.0.rs:(.text._ZN3ffi4easy4Easy6setopt20h1335928551378549339E+0x160): undefined reference to `curl_easy_setopt'
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `curl_example`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name curl_example --crate-type bin -C opt-level=3 --out-dir /home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release --emit=dep-info,link --target arm-unknown-linux-gnueabihf -C ar=arm-linux-gnueabihf-ar -C linker=arm-linux-gnueabihf-gcc -L dependency=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release -L dependency=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps --extern curl=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/deps/libcurl-8828a61714ae0eb4.rlib -L /home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/curl-sys-b582fd2220a1331e/out/lib -L native=/home/frederick/rust/curl_example/target/arm-unknown-linux-gnueabihf/release/build/openssl-sys-765ddf9de3c5179c/out` (exit code: 101)

But I did successfully cross-compile curl-rust itself for both x86_64-pc-windows-gnu and arm-unknown-linux-gnueabihf which made it weirder.

How to fix these problems? Did I miss any configurations?

Need to keep up with std::ascii reform

When building cargo with (very) recent rustc, the following error is reported:

/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-0.1.3/src/ffi/easy.rs:153:37: 153:55 error: type `collections::string::String` does not implement any method in scope named `into_ascii_lower`
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/curl-0.1.3/src/ffi/easy.rs:153         let name = name.to_string().into_ascii_lower();

If I'm right, this is since rust-lang/rust@070ab63 , and the cause of the error is also present in current HEAD of curl-rust.
(PS: I know that cargo officially does not necessarily build with latest rustc, but both cargo and curl will eventually run into this issue.)

Build fails on Windows when there's a space in the build location's path

This is not very surprising, having a space in my username has caused me grief before. The issue occurs with both -gcc and -msvc compilers. Other rust libraries that build C code like miniz-sys work fine. Edit: Though I've just had the same issue with libz-sys. I suppose running just a C compiler works fine with spaces, but unix utilities like sh and sed and whatnot don't work when running the configure script.

I'll see if I can put a PR together since I need this to build rustup.

failed to run custom build command for `curl-sys v0.2.0 (https://github.com/alexcrichton/curl-rust?rev=ccf35d3e#ccf35d3e)`
Process didn't exit successfully: `C:\Users\Matt Ickstadt\Code\Rust\multirust-rs\target\debug\build\curl-sys-80af2ac2b0635904\build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=C:\Users\Matt Ickstadt\Code\Rust\multirust-rs\target\debug\build\curl-sys-80af2ac2b0635904\out/lib
cargo:rustc-link-lib=static=curl
cargo:root=C:\Users\Matt Ickstadt\Code\Rust\multirust-rs\target\debug\build\curl-sys-80af2ac2b0635904\out
cargo:include=C:\Users\Matt Ickstadt\Code\Rust\multirust-rs\target\debug\build\curl-sys-80af2ac2b0635904\out/include
cargo:rustc-flags=-l ws2_32
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("i686-pc-windows-gnu")
debug=true opt-level=0
HOST = Some("i686-pc-windows-gnu")
TARGET = Some("i686-pc-windows-gnu")
TARGET = Some("i686-pc-windows-gnu")
HOST = Some("i686-pc-windows-gnu")
CC_i686-pc-windows-gnu = None
CC_i686_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some("i686-pc-windows-gnu")
HOST = Some("i686-pc-windows-gnu")
CFLAGS_i686-pc-windows-gnu = None
CFLAGS_i686_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
running: "sh" "/c/Users/Matt Ickstadt/.cargo/git/checkouts/curl-rust-3ae0a5088171a1a0/ccf35d3e/curl-sys/curl/configure" "--with-winssl" "--enable-static=yes" "--enable-shared=no" "--enable-optimize" "--prefix=/c/Users/Matt Ickstadt/Code/Rust/multirust-rs/target/debug/build/curl-sys-80af2ac2b0635904/out" "--without-librtmp" "--without-libidn" "--without-libssh2" "--without-nghttp2" "--disable-ldap" "--disable-ldaps" "--disable-ftp" "--disable-rtsp" "--disable-dict" "--disable-telnet" "--disable-tftp" "--disable-pop3" "--disable-imap" "--disable-smtp" "--disable-gopher" "--disable-manual" "--disable-smb" "--disable-sspi"
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... no
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking whether to disable dependency on -lrt... (assumed no)
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ar... /c/msys64/mingw64/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc.exe
checking whether the C compiler works... no

--- stderr
/c/Users/Matt Ickstadt/.cargo/git/checkouts/curl-rust-3ae0a5088171a1a0/ccf35d3e/curl-sys/curl/configure: line 3663: test: /c/Users/Matt: binary operator expected
/usr/bin/sed: can't read /c/Users/Matt: No such file or directory
/usr/bin/sed: can't read Ickstadt/.cargo/git/checkouts/curl-rust-3ae0a5088171a1a0/ccf35d3e/curl-sys/curl/include/curl/curlver.h: No such file or directory
/c/Users/Matt Ickstadt/.cargo/git/checkouts/curl-rust-3ae0a5088171a1a0/ccf35d3e/curl-sys/curl/configure: line 3965: cd: /c/Users/Matt: No such file or directory
configure: error: in `/c/Users/Matt Ickstadt/Code/Rust/multirust-rs/target/debug/build/curl-sys-80af2ac2b0635904/out/build':
configure: error: C compiler cannot create executables
See `config.log' for more details
thread '<main>' panicked at '
command did not execute successfully, got: exit code: 77

build script failed, must exit now', C:\Users\Matt Ickstadt\.cargo\git\checkouts\curl-rust-3ae0a5088171a1a0\ccf35d3e\curl-sys\build.rs:158
note: Run with `RUST_BACKTRACE=1` for a backtrace.

curl and openssl crates do not work together

A simple project with these two dependencies does not work:

[dependencies]

curl = "*"
openssl = "*"

cargo build

native library `openssl` is being linked to by more than one package, and can only be linked to by one package

  openssl-sys v0.6.0
  openssl-sys v0.5.5

On OSX with rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)

Building on windows, tutorial and suggestions

I am happy to help by writing out the details in markdown somewhere but I think this issue of building this crate on windows should be addressed. Currently, on a standard version of windows without linux tools installed such as sh, this build will fail. This came up when I was trying to install cargo-edit on windows via cargo install cargo-edit which is one of my favorite linux programs for working with rust. I did receive the useful message "is sh not installed?" but it was perhaps a bit too short. Sadly, in version 0.2.18 that is used by cargo-edit, this message did not appear. I found the message by cloning this repo and trying to build. I still do not know the best way forward. Is MinGW expected? Something else?

Thanks for the advice. I think whatever information is included in the answer should in some way probably be added to the readme.

How to write headers data to HashMap?

I want to save headers information into HasMap.
I do this

    let mut headers: HashMap<&str, &str> = HashMap::new();
    {
        let mut transfer = easy.transfer();
        transfer.header_function(|header| {
            let v: Vec<&str> = str::from_utf8(header).unwrap().trim().split(": ").collect();
            if v.len() == 2 { 
                headers.insert(v[0], v[1]);
            }
            true
        }).unwrap();       

        transfer.perform().unwrap();
    }

But I got this error :

src\main.rs:48:32: 48:54 error: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements [E0495]
src\main.rs:48             let v: Vec<&str> = str::from_utf8(header).unwrap().trim().split(": ").collect();
                                              ^~~~~~~~~~~~~~~~~~~~~~
src\main.rs:47:43: 56:10 note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the block at 47:42...
src\main.rs:47         transfer.header_function(|header| {
                                                         ^
src\main.rs:48:47: 48:53 note: ...so that reference does not outlive borrowed content
src\main.rs:48             let v: Vec<&str> = str::from_utf8(header).unwrap().trim().split(": ").collect();
                                                             ^~~~~~
src\main.rs:47:9: 56:11 note: but, the lifetime must be valid for the method call at 47:8...
src\main.rs:47         transfer.header_function(|header| {
                       ^
src\main.rs:47:34: 56:10 note: ...so that argument is valid for the call
src\main.rs:47         transfer.header_function(|header| {

Can you help me?

How to write received data in String?

How can I write received data in String?
I do this

let html: String = String::new();
easy.write_function(|data| {
        let html = String::from_utf8(Vec::from(data)).unwrap();
        Ok(data.len())
}).unwrap();
println!("{}", html);

But there is nothing in html string variable. I think let html = String::from_utf8 ... is local and not the same as let html: String ...

curl is not thread-safe in certain circumstances

  • rustc: 1.6.0 (c30b771ad 2016-01-19)
  • curl-rust: 0.2.16

curl --version:

curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp 
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

Note that the AsynchDNS feature is not present.

extern crate curl;

use std::thread::{ spawn, sleep };
use std::time::Duration;

fn main() {
    const REQUESTS: usize = 2_000;
    const THREADS: usize = 8;
    const URL: &'static str = "http://mirror.internode.on.net/pub/test/5meg.test5";

    let mut handles = vec![];
    for _ in 0..THREADS {
        handles.push(spawn(|| {
            let count = REQUESTS / THREADS;

            for _ in 0..count {
                curl::http::handle()
                .connect_timeout(30_000)
                .timeout(0)
                .get(URL)
                .exec()
                .unwrap();

                sleep(Duration::from_millis(100));
            }
        }));
    }

    for h in handles {
        h.join().unwrap();
    }
}

Snipped backtrace:

*** longjmp causes uninitialized stack frame ***: target/debug/curl-segfault terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7fc64a3000e7]
/lib/x86_64-linux-gnu/libc.so.6(+0xf0079)[0x7fc64a300079]
/lib/x86_64-linux-gnu/libc.so.6(__longjmp_chk+0x33)[0x7fc64a2fffe3]
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4(+0xbc35)[0x7fc64b234c35]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf0a0)[0x7fc64a7c00a0]
/lib/x86_64-linux-gnu/libpthread.so.0(pthread_join+0x115)[0x7fc64a7b8ee5]

This particular backtrace does not indicate that it could be due to missing the AsynchDNS feature. However, http://curl.haxx.se/libcurl/c/threadsafe.html outlines several details which could lead to unsafety, one of which involves unsafe SSL libraries (as this backtrace suggests).

On another machine which I do not currently have access to, the Curl_resolv function was implicated by the backtrace, which initially lead me to CURLOPT_NOSIGNAL (and thus the AsynchDNS feature). I was unable to verify that this is a potential solution to the problem, as curl-rust doesn't seem to make it available for use.

Problem with cargo

If something is based on curl-rust and I try to install it with cargo I get the following error.

Unable to update https://github.com/carllerche/curl-rust

Caused by:
  failed to update submodules

Caused by:
  [4] Reference 'refs/heads/master' not found

I don't know if that is a cargo problem, but I experienced it with curl-rust.

Can't build on Windows: syntax error near unexpected token `('

I did cargo build in curl-sys.

I wonder if it may be because I'm using sh.exe from Git.

running: make '-j4'
CDPATH="${ZSH_VERSION+.}:" && cd /c/dev/curl-rust/curl-sys/curl && C:/Program Files (x86)/Git/bin/sh.exe "/c/dev/curl-ru
st/curl-sys/curl/missing" --run autoconf
Makefile:738: recipe for target '/c/dev/curl-rust/curl-sys/curl/Makefile.in' failed
Makefile:766: recipe for target '/c/dev/curl-rust/curl-sys/curl/configure' failed

--- stderr
configure: WARNING: disabling built-in manual
"C:/Program Files (x86)/Git/bin/sh.exe": -c: line 4: syntax error near unexpected token `('
"C:/Program Files (x86)/Git/bin/sh.exe": -c: line 4: `      CDPATH="${ZSH_VERSION+.}:" && cd /c/dev/curl-rust/curl-sys/curl && C:/Program Files (x86)/Git/bin/sh.exe "/c/dev/curl-rust/curl-sys/curl/missing" --run automake-1.14 --foreign \'
"C:/Program Files (x86)/Git/bin/sh.exe": -c: line 0: syntax error near unexpected token `('
"C:/Program Files (x86)/Git/bin/sh.exe": -c: line 0: `CDPATH="${ZSH_VERSION+.}:" && cd /c/dev/curl-rust/curl-sys/curl &&
 C:/Program Files (x86)/Git/bin/sh.exe "/c/dev/curl-rust/curl-sys/curl/missing" --run autoconf'
make: *** [/c/dev/curl-rust/curl-sys/curl/Makefile.in] Error 258
make: *** Waiting for unfinished jobs....
make: *** [/c/dev/curl-rust/curl-sys/curl/configure] Error 258
task '<main>' panicked at 'assertion failed: cmd.stdout(InheritFd(1)).stderr(InheritFd(2)).status().unwrap().success()',
 build.rs:122

DELETE and PATCH Functionality

I've been working on creating Github API Bindings using this library and it's been working out great, the only problem being that a DELETE or PATCH request is not implemented. Even if libcurl doesn't provide it using the easy interface it could be implemented with this C function. Are there plans to implement this sometime in the future? If they are is there some way I could help to implement it and how would I go about doing so?

curl_formadd() is unavailable

I'm currently trying to write a file upload program. This requires sending data to a form (analogous to curl -F from the command line). I've been told that the equivalent function in native libcurl is curl_formadd(), but this function is commented out in the curl_sys crate. And, of course, this means there's no corresponding function in the curl crate.

Failed to build due to deprecated

/rust/curl-rust/src/lib.rs:8:14: 8:36 error: #[phase] is deprecated; use #[macro_use], #[plugin], and/or #    [no_link]
rust/curl-rust/src/lib.rs:8 #[cfg(test)] #[phase(plugin, link)] extern crate log;

rust/curl-rust/src/ffi/opt.rs:4:5: 4:23 error: unresolved import `std::c_str::ToCStr`. Could not find `c_str` in `std`
rust/curl-rust/src/ffi/opt.rs:4 use std::c_str::ToCStr;
                                                       ^~~~~~~~~~~~~~~~~~
rust/curl-rust/src/ffi/easy.rs:4:5: 4:21 error: unresolved import `std::c_vec::CVec`. Could not find `c_vec` in `std`
rust/curl-rust/src/ffi/easy.rs:4 use std::c_vec::CVec;
                                                        ^~~~~~~~~~~~~~~~
rust/curl-rust/src/ffi/err.rs:1:5: 1:24 error: unresolved import `std::c_str::CString`. Could not find `c_str` in `std`
rust/curl-rust/src/ffi/err.rs:1 use std::c_str::CString;
                                                       ^~~~~~~~~~~~~~~~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.