/[winpt]/trunk/Src/wptHTTP.cpp
ViewVC logotype

Diff of /trunk/Src/wptHTTP.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 307 by twoaday, Sun Nov 5 08:57:45 2006 UTC revision 308 by twoaday, Fri Mar 23 14:26:30 2007 UTC
# Line 1  Line 1 
1  /* wptHTTP.cpp - Generic HTTP support  /* wptHTTP.cpp - Generic HTTP support
2   *      Copyright (C) 2004, 2005, 2006 Timo Schulz   *      Copyright (C) 2004, 2005, 2006, 2007 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 54  wHTTP::wHTTP (const char *_host, int _po Line 54  wHTTP::wHTTP (const char *_host, int _po
54  wHTTP::wHTTP (const char *_url)  wHTTP::wHTTP (const char *_url)
55  {  {
56      reset ();      reset ();
57        open (_url);
58    }
59    
     if (extractHostInfo (_url, &this->host, &this->url))  
         return;      
60    
61      /* FIXME: we should throw an exception in case of an error. */  /* Open a connection to the given URL. */
62    int
63    wHTTP::open (const char *_url)
64    {
65        releaseMem ();
66        
67        if (extractHostInfo (_url, &this->host, &this->url))
68            return -1;
69        
70      if (!sendRequest (this->host, this->port, this->url))      if (!sendRequest (this->host, this->port, this->url))
71          parseResponse (&statcode);          return parseResponse (&statcode);
72        
73        return 0;
74  }  }
75    
76    
# Line 549  wHTTP::parseResponse (int *_statcode) Line 559  wHTTP::parseResponse (int *_statcode)
559  }  }
560    
561    
562  /* Destroy HTTP object. */  /* Release all used structures. */
563  wHTTP::~wHTTP (void)  void
564    wHTTP::releaseMem (void)
565  {  {
566      http_head_t h;      http_head_t h;
567            
# Line 559  wHTTP::~wHTTP (void) Line 570  wHTTP::~wHTTP (void)
570          free (resp_headers);          free (resp_headers);
571          resp_headers = h;          resp_headers = h;
572      }      }
573        resp_headers = NULL;
574      while (req_headers) {      while (req_headers) {
575          h = req_headers->next;          h = req_headers->next;
576          free (req_headers);          free (req_headers);
577          req_headers = h;          req_headers = h;
578      }      }
579        req_headers = NULL;
580      safe_free (url);      safe_free (url);
581      safe_free (host);      safe_free (host);
582    }
583    
584    
585    /* Destroy HTTP object. */
586    wHTTP::~wHTTP (void)
587    {
588        releaseMem ();
589      if (fd != 0) {      if (fd != 0) {
590          closesocket (fd);          closesocket (fd);
591          fd = 0;          fd = 0;

Legend:
Removed from v.307  
changed lines
  Added in v.308

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26