*** sp-1.3.4/lib/URLStorage.cxx Fri Aug 22 08:10:56 1997 --- lq-sp-1.3.4.1/lib/URLStorage.cxx Sun Sep 17 22:21:17 2000 *************** *** 18,23 **** --- 18,24 ---- #define SP_HAVE_SOCKET #else #ifdef SP_HAVE_SOCKET + #include #include #include #include *************** *** 78,84 **** public: HttpSocketStorageObject(SOCKET fd, Boolean mayRewind, const StringC &hostStr); ~HttpSocketStorageObject(); ! Boolean open(const String &path, Messenger &); Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); Boolean seekToStart(Messenger &); static SOCKET openHttp(const String &host, --- 79,88 ---- public: HttpSocketStorageObject(SOCKET fd, Boolean mayRewind, const StringC &hostStr); ~HttpSocketStorageObject(); ! Boolean open(const String &host, ! unsigned short port, ! const String &path, ! Messenger &); Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); Boolean seekToStart(Messenger &); static SOCKET openHttp(const String &host, *************** *** 268,280 **** StringC hostStr; for (i = 0; i < host.size(); i++) hostStr += host[i]; - host += '\0'; SOCKET fd = HttpSocketStorageObject::openHttp(host, port, hostStr, mgr); if (fd == INVALID_SOCKET) return 0; HttpSocketStorageObject *p = new HttpSocketStorageObject(fd, mayRewind, hostStr); ! if (!p->open(path, mgr)) { delete p; return 0; } --- 272,283 ---- StringC hostStr; for (i = 0; i < host.size(); i++) hostStr += host[i]; SOCKET fd = HttpSocketStorageObject::openHttp(host, port, hostStr, mgr); if (fd == INVALID_SOCKET) return 0; HttpSocketStorageObject *p = new HttpSocketStorageObject(fd, mayRewind, hostStr); ! if (!p->open(host, port, path, mgr)) { delete p; return 0; } *************** *** 360,370 **** #ifdef SP_HAVE_SOCKET ! SOCKET HttpSocketStorageObject::openHttp(const String &host, unsigned short port, const StringC &hostStr, Messenger &mgr) { #ifdef WINSOCK if (!winsockIniter.init(mgr)) return INVALID_SOCKET; --- 363,376 ---- #ifdef SP_HAVE_SOCKET ! SOCKET HttpSocketStorageObject::openHttp(const String &theHost, unsigned short port, const StringC &hostStr, Messenger &mgr) { + String host = theHost; + host += '\0'; + #ifdef WINSOCK if (!winsockIniter.init(mgr)) return INVALID_SOCKET; *************** *** 450,456 **** (void)closesocket(fd_); } ! Boolean HttpSocketStorageObject::open(const String &path, Messenger &mgr) { path_ = path; String request; --- 456,465 ---- (void)closesocket(fd_); } ! Boolean HttpSocketStorageObject::open(const String &host, ! unsigned short port, ! const String &path, ! Messenger &mgr) { path_ = path; String request; *************** *** 458,465 **** --- 467,486 ---- request += path_; request += ' '; request.append("HTTP/1.0\r\n", 10); + request.append("Host: ", 6); + if (!isdigit((unsigned char)host[0])) { + request += host; + if (port != 80) { + char portstr[sizeof(unsigned short)*3 + 1]; + sprintf(portstr, "%u", port); + request.append(":", 1); + request.append(portstr, strlen(portstr)); + } + } + request.append("\r\n", 2); request.append("Accept: */*\r\n", 13); request.append("\r\n", 2); + // FIXME check length of write if (writesocket(fd_, request.data(), request.size()) == SOCKET_ERROR) { ParentLocationMessenger(mgr).message(URLStorageMessages::writeError,