ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Search/HttpHandler.cpp
(Generate patch)

Comparing trunk/Search/HttpHandler.cpp (file contents):
Revision 211 by douglas, 2003-07-19T18:46:12-07:00 vs.
Revision 212 by douglas, 2003-07-19T21:00:25-07:00

# Line 46 | Line 46
46   //
47   // Douglas Thrift
48   //
49 < // $Id: HttpHandler.cpp,v 1.22 2003/07/20 01:46:12 douglas Exp $
49 > // $Id: HttpHandler.cpp,v 1.23 2003/07/20 04:00:25 douglas Exp $
50  
51   #include "HttpHandler.h"
52  
# Line 58 | Line 58
58   #include <sys/socket.h>
59   #include <netinet/in.h>
60   #include <netdb.h>
61 +
62 + inline int closesocket(SOCKET s) { return close(s); }
63   #endif
64  
65   HttpHandler::HttpHandler()
# Line 184 | Line 186 | bool HttpHandler::handle(URL &url, const
186                  unsigned dot = line.find('.');
187                  unsigned space = line.find(' ');
188  
189 <                unsigned major = strtoul(line.substr(5, dot - 5).c_str(), 0, 10);
190 <                unsigned minor = strtoul(line.substr(dot + 1, space - dot - 1).c_str(),
191 <                        0, 10);
189 >                unsigned major;
190 >                unsigned minor;
191 >
192 >                istringstream number(line.substr(5, dot - 5) + " " + line.substr(dot
193 >                        + 1, space - dot - 1));
194 >
195 >                number >> major;
196 >                number >> minor;
197  
198                  if (major > 1)
199                  {
# Line 196 | Line 203 | bool HttpHandler::handle(URL &url, const
203                          return answer;
204                  }
205  
206 <                response = code(strtoul(line.substr(space + 1).c_str(), 0, 10));
206 >                number.clear();
207 >                number.str(line.substr(space + 1, 3));
208 >                number >> response;
209  
210                  if (response < ok) do line = getline(); while (line != "");
211          }
# Line 221 | Line 230 | bool HttpHandler::handle(URL &url, const
230                          }
231                          else if (field == "Content-Length")
232                          {
233 <                                length = strtoul(value.c_str(), 0, 10);
233 >                                istringstream number(value);
234 >
235 >                                number >> length;
236                          }
237                          else if (field == "Location")
238                          {
# Line 346 | Line 357 | void HttpHandler::populate()
357  
358                  do
359                  {
360 <                        chunk = strtoul(getline().c_str(), 0, 16);
360 >                        istringstream number(getline());
361 >
362 >                        number.setf(ios_base::hex, ios_base::basefield);
363 >                        number >> chunk;
364  
365                          unsigned left = chunk;
366  
# Line 819 | Line 833 | bool HttpHandler::starttls()
833          return true;
834   }
835   #endif
836 +
837 + istream& operator>>(istream& is, HttpHandler::code& data)
838 + {
839 +        int number;
840 +
841 +        is >> number;
842 +
843 +        data = HttpHandler::code(number);
844 +
845 +        return is;
846 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines