perl

 view release on metacpan or  search on metacpan

cpan/Win32/Win32.pm  view on Meta::CPAN

persistent identifier in a distributed setting. To a very high degree
of certainty this function returns a unique value. No other
invocation, on the same or any other system (networked or not), should
return the same value.

The return value is formatted according to OLE conventions, as groups
of hex digits with surrounding braces.  For example:

    {09531CF1-D0C7-4860-840C-1C8C8735E2AD}

=item Win32::HttpGetFile(URL, FILENAME [, IGNORE_CERT_ERRORS])

Uses the WinHttp library to download the file specified by the URL
parameter to the local file specified by FILENAME. The optional third
parameter, if true, indicates that certficate errors are to be ignored
for https connections; please use with caution in a safe environment,
such as when testing locally using a self-signed certificate.

Only http and https protocols are supported.  Authentication is not
supported.  The function is not available when building with gcc prior to
4.8.0 because the WinHttp library is not available.

cpan/Win32/Win32.pm  view on Meta::CPAN

context also returns, in addition to the boolean status, a second
value containing message text related to the status.

If the call fails, C<Win32::GetLastError()> will return a numeric
error code, which may be a system error, a WinHttp error, or a
user-defined error composed of 1e9 plus the HTTP status code.

Scalar context example:

    print Win32::GetLastError()
        unless Win32::HttpGetFile('http://example.com/somefile.tar.gz',
                                  '.\file.tgz');

List context example:

    my ($ok, $msg) = Win32::HttpGetFile('http://example.com/somefile.tar.gz',
                                        '.\file.tgz');
    if ($ok) {
        print "Success!: $msg\n";
    }
    else {
        print "Failure!: $msg\n";
        my $err = Win32::GetLastError();
        if ($err > 1e9) {
            printf "HTTP status: %d\n", ($err - 1e9);
        }

cpan/Win32/Win32.xs  view on Meta::CPAN

    );

    if (status == ERROR_SUCCESS && val == 1)
        XSRETURN_YES;

    XSRETURN_NO;
}

#ifdef WINHTTPAPI

XS(w32_HttpGetFile)
{
    dXSARGS;
    WCHAR *url = NULL, *file = NULL, *hostName = NULL, *urlPath = NULL;
    bool bIgnoreCertErrors = FALSE;
    WCHAR msgbuf[ONE_K_BUFSIZE];
    BOOL  bResults = FALSE;
    HINTERNET  hSession = NULL,
               hConnect = NULL,
               hRequest = NULL;
    HANDLE hOut = INVALID_HANDLE_VALUE;
    BOOL   bParsed = FALSE,
           bAborted = FALSE,
           bFileError = FALSE,
           bHttpError = FALSE;
    DWORD error = 0;
    URL_COMPONENTS urlComp;
    LPCWSTR acceptTypes[] = { L"*/*", NULL };
    DWORD dwHttpStatusCode = 0, dwQuerySize = 0;

    if (items < 2 || items > 3)
        croak("usage: Win32::HttpGetFile($url, $file[, $ignore_cert_errors])");

    url = sv_to_wstr(aTHX_ ST(0));
    file = sv_to_wstr(aTHX_ ST(1));

    if (items == 3)
        bIgnoreCertErrors = (BOOL)SvIV(ST(2));

    /* Initialize the URL_COMPONENTS structure, setting the required
     * component lengths to non-zero so that they get populated.
     */

cpan/Win32/Win32.xs  view on Meta::CPAN


        if(WinHttpGetProxyForUrl(hSession,
                                url,
                                &AutoProxyOptions,
                                &ProxyInfo)) {
            if(!WinHttpSetOption(hRequest,
                                WINHTTP_OPTION_PROXY,
                                &ProxyInfo,
                                cbProxyInfoSize)) {
                bAborted = TRUE;
                Perl_warn(aTHX_ "Win32::HttpGetFile: setting proxy options failed");
            }
            Safefree(ProxyInfo.lpszProxy);
            Safefree(ProxyInfo.lpszProxyBypass);
        }
    }

    /* Send a request. */
    if (hRequest && !bAborted)
        bResults = WinHttpSendRequest(hRequest,
                                      WINHTTP_NO_ADDITIONAL_HEADERS,

cpan/Win32/Win32.xs  view on Meta::CPAN

    newXS("Win32::GetConsoleOutputCP", w32_GetConsoleOutputCP, file);
    newXS("Win32::GetOEMCP", w32_GetOEMCP, file);
    newXS("Win32::SetConsoleCP", w32_SetConsoleCP, file);
    newXS("Win32::SetConsoleOutputCP", w32_SetConsoleOutputCP, file);
    newXS("Win32::GetProcessPrivileges", w32_GetProcessPrivileges, file);
    newXS("Win32::IsDeveloperModeEnabled", w32_IsDeveloperModeEnabled, file);
#ifdef __CYGWIN__
    newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file);
#endif
#ifdef WINHTTPAPI
    newXS("Win32::HttpGetFile", w32_HttpGetFile, file);
#endif
    XSRETURN_YES;
}



( run in 2.935 seconds using v1.01-cache-2.11-cpan-a5abf4f5562 )