cURL / Mailing Lists / curl-users / Single Mail

curl-users

[ curl-Bugs-413905 ] persistant example does not work on w2k

From: <noreply_at_sourceforge.net>
Date: Wed, 04 Apr 2001 21:02:37 -0700

Bugs item #413905, was updated on 2001-04-04 21:02
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=413905&group_id=976

Category: libcurl
Group: wrong content
Status: Open
Priority: 5
Submitted By: T. Ho (bht67)
Assigned to: Daniel Stenberg (bagder)
Summary: persistant example does not work on w2k

Initial Comment:
persistant example returns the following when tried to
open another document using the same connection.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
Your browser sent a request that this server could not
understand.<P>
Client sent malformed Host header<P>
<HR>
<ADDRESS>Apache/1.3.17 Server at www.contactor.se Port
80</ADDRESS>
</BODY></HTML>

/******************************************************
***********************
 * _ _ ____ _
 * Project ___| | | | _ \| |
 * / __| | | | |_) | |
 * | (__| |_| | _ <| |___
 * \___|\___/|_| \_\_____|
 *
 * $Id: persistant.c,v 1.1 2001/03/05 16:56:10 bagder
Exp $
 */

#include <stdio.h>
//#include <unistd.h>

#include <curl/curl.h>

/* to make this work under windows, use the win32-
functions from the
   docs/examples/win32socket.c file as well */
#include <windows.h>

/* to make this work under windows, use the win32-
functions from the
   win32socket.c file as well */
/*
 * These are example functions doing socket init that
Windows
 * require. If you don't use windows, you can safely
ignore this crap.
 */

static void win32_cleanup(void)
{
  WSACleanup();
}

static CURLcode win32_init(void)
{
  WORD wVersionRequested;
  WSADATA wsaData;
  int err;
  wVersionRequested = MAKEWORD(1, 1);
    
  err = WSAStartup(wVersionRequested, &wsaData);
    
  if (err != 0)
    /* Tell the user that we couldn't find a useable
*/
    /* winsock.dll. */
    return 1;
    
  /* Confirm that the Windows Sockets DLL supports
1.1.*/
  /* Note that if the DLL supports versions greater */
  /* than 1.1 in addition to 1.1, it will still return
*/
  /* 1.1 in wVersion since that is the version we */
  /* requested. */
    
  if ( LOBYTE( wsaData.wVersion ) != 1 ||
       HIBYTE( wsaData.wVersion ) != 1 ) {
    /* Tell the user that we couldn't find a useable
*/

    /* winsock.dll. */
    WSACleanup();
    return 1;
  }
  return 0; /* 0 is ok */
}

/* This example REQUIRES libcurl 7.7 or later */
#if (LIBCURL_VERSION_NUM < 0x070700)
#error Too old libcurl version, upgrade or stay away.
#endif

int main(int argc, char **argv)
{
  CURL *curl;
  CURLcode res;

#ifdef MALLOCDEBUG
  /* this sends all memory debug messages to a
specified logfile */
  curl_memdebug("memdump");
#endif

  win32_init();
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_HEADER, 0);

    /* get the first document */
    curl_easy_setopt(curl,
CURLOPT_URL, "http://curl.haxx.se/");
    res = curl_easy_perform(curl);

    /* get another document from the same server using
the same
       connection */
    curl_easy_setopt(curl,
CURLOPT_URL, "http://curl.haxx.se/");
    res = curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);
        win32_cleanup();
  }

  return 0;
}

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

You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=413905&group_id=976
Received on 2001-04-05