- Not built by default from tarball Makefile; built by default in ecere.epj configurations
extern char * strstr(const char * , const char * );
+extern void * memcpy(void * , const void * , size_t size);
+
extern int toupper(int);
extern char * strcat(char * , const char * );
if(addedPath)
{
-char fileName[797] = "", archiveName[797] = "", * file;
+char fileName[797] = "", archiveName[797] = "", * file = (((void *)0));
int c = 0;
unsigned int isURL = 0x0;
+unsigned int isArchive = __ecereNameSpace__ecere__sys__SplitArchivePath(string, archiveName, &file);
char * urlFileName;
+char * protocolSymbol;
-if(__ecereNameSpace__ecere__sys__SplitArchivePath(string, archiveName, &file))
-strcpy(fileName, file);
-else
+strcpy(fileName, isArchive ? file : string);
+if(!isArchive)
{
-strcpy(fileName, string);
-}
-if(strstr(string, "http://") == string)
+protocolSymbol = (fileName[0] && fileName[0] != '.' && fileName[0] != '/' && fileName[0] != '\\' && fileName[1] != ':') ? strstr(fileName, "://") : (((void *)0));
+if(protocolSymbol)
{
-char * slash = strstr(fileName + 7, "/");
+char * slash = strstr(protocolSymbol + 3, "/");
isURL = 0x1;
if(slash)
else
urlFileName = fileName + strlen(fileName);
}
-if(strstr(addedPath, "http://") == addedPath)
+}
+protocolSymbol = (addedPath[0] && addedPath[0] != '.' && addedPath[0] != '/' && addedPath[0] != '\\' && addedPath[1] != ':') ? strstr(addedPath, "://") : (((void *)0));
+if(protocolSymbol)
{
-strcpy(fileName, "http://");
+int len = protocolSymbol - addedPath + 3;
+
+memcpy(fileName, addedPath, len);
+fileName[len] = (char)0;
isURL = 0x1;
-c = 7;
+c = len;
}
else if(__ecereNameSpace__ecere__com__GetRuntimePlatform() == 1)
{
if(addedPath)
{
-char fileName[797] = "", archiveName[797] = "", * file;
+char fileName[797] = "", archiveName[797] = "", * file = (((void *)0));
int c = 0;
unsigned int isURL = 0x0;
+unsigned int isArchive = __ecereNameSpace__ecere__sys__SplitArchivePath(string, archiveName, &file);
char * urlFileName;
+char * protocolSymbol;
-if(__ecereNameSpace__ecere__sys__SplitArchivePath(string, archiveName, &file))
-strcpy(fileName, file);
-else
+strcpy(fileName, isArchive ? file : string);
+if(!isArchive)
{
-strcpy(fileName, string);
-}
-if(strstr(string, "http://") == string)
+protocolSymbol = (fileName[0] && fileName[0] != '.' && fileName[0] != '/' && fileName[0] != '\\' && fileName[1] != ':') ? strstr(fileName, "://") : (((void *)0));
+if(protocolSymbol)
{
-char * slash = strstr(fileName + 7, "/");
+char * slash = strstr(protocolSymbol + 3, "/");
isURL = 0x1;
if(slash)
else
urlFileName = fileName + strlen(fileName);
}
-if(strstr(addedPath, "http://") == addedPath)
+}
+protocolSymbol = (addedPath[0] && addedPath[0] != '.' && addedPath[0] != '/' && addedPath[0] != '\\' && addedPath[1] != ':') ? strstr(addedPath, "://") : (((void *)0));
+if(protocolSymbol)
{
-strcpy(fileName, "http://");
+int len = protocolSymbol - addedPath + 3;
+
+memcpy(fileName, addedPath, len);
+fileName[len] = (char)0;
isURL = 0x1;
-c = 7;
+c = len;
}
else if(runtimePlatform == 1)
{
string[c] = (char)0;
}
-extern void * memcpy(void * , const void * , size_t size);
-
char * __ecereNameSpace__ecere__sys__CopyString(char * string)
{
if(string)
CFLAGS += -DECERE_NOGL
endif
+CFLAGS += -DECERE_NOSSL
"X11",
"Xext",
"Xrender",
- "GL"
+ "GL",
+ "ssl",
+ "crypto"
],
"LibraryDirs" : [
"/usr/X11R6/lib"
"shell32",
"winspool",
"imm32",
- "ungif"
+ "ungif",
+ "eay32",
+ "ssleay32"
],
"LibraryDirs" : [
"../deps/zlib/obj/release.$(PLATFORM)$(COMPILER_SUFFIX)",
"X11",
"Xext",
"Xrender",
- "GL"
+ "GL",
+ "ssl",
+ "crypto"
],
"LibraryDirs" : [
"$(SYSROOT)/usr/X11/lib",
]
},
"Service.ec",
- "Socket.ec"
+ "Socket.ec",
+ "SSLSocket.ec"
],
"Configurations" : [
{
bool modified = false;
if(addedPath)
{
- char fileName[MAX_LOCATION] = "", archiveName[MAX_LOCATION] = "", * file;
+ char fileName[MAX_LOCATION] = "", archiveName[MAX_LOCATION] = "", * file = null;
int c = 0;
bool isURL = false;
+ bool isArchive = SplitArchivePath(string, archiveName, &file);
char * urlFileName;
+ char * protocolSymbol;
- if(SplitArchivePath(string, archiveName, &file))
- strcpy(fileName, file);
- else
- {
- strcpy(fileName, string);
- }
+ strcpy(fileName, isArchive ? file : string);
- if(strstr(string, "http://") == string)
+ if(!isArchive) // TODO: Support for PathCat'ing .. outside of archive
{
- char * slash = strstr(fileName + 7, "/");
- isURL = true;
- if(slash)
- urlFileName = slash;
- else
- urlFileName = fileName + strlen(fileName);
+ protocolSymbol = (fileName[0] && fileName[0] != '.' && fileName[0] != '/' && fileName[0] != '\\' && fileName[1] != ':') ? strstr(fileName, "://") : null;
+ if(protocolSymbol)
+ {
+ char * slash = strstr(protocolSymbol + 3, "/");
+ isURL = true;
+ if(slash)
+ urlFileName = slash;
+ else
+ urlFileName = fileName + strlen(fileName);
+ }
}
- if(strstr(addedPath, "http://") == addedPath)
+
+ protocolSymbol = (addedPath[0] && addedPath[0] != '.' && addedPath[0] != '/' && addedPath[0] != '\\' && addedPath[1] != ':') ? strstr(addedPath, "://") : null;
+ if(protocolSymbol)
{
- strcpy(fileName, "http://");
+ int len = protocolSymbol - addedPath + 3;
+ memcpy(fileName, addedPath, len);
+ fileName[len] = 0;
isURL = true;
- c = 7;
+ c = len;
}
else if(GetRuntimePlatform() == win32)
{
bool modified = false;
if(addedPath)
{
- char fileName[MAX_LOCATION] = "", archiveName[MAX_LOCATION] = "", * file;
+ char fileName[MAX_LOCATION] = "", archiveName[MAX_LOCATION] = "", * file = null;
int c = 0;
bool isURL = false;
+ bool isArchive = SplitArchivePath(string, archiveName, &file);
char * urlFileName;
+ char * protocolSymbol;
- if(SplitArchivePath(string, archiveName, &file))
- strcpy(fileName, file);
- else
- {
- strcpy(fileName, string);
- }
+ strcpy(fileName, isArchive ? file : string);
- if(strstr(string, "http://") == string)
+ if(!isArchive) // TODO: Support for PathCat'ing .. outside of archive
{
- char * slash = strstr(fileName + 7, "/");
- isURL = true;
- if(slash)
- urlFileName = slash;
- else
- urlFileName = fileName + strlen(fileName);
+ protocolSymbol = (fileName[0] && fileName[0] != '.' && fileName[0] != '/' && fileName[0] != '\\' && fileName[1] != ':') ? strstr(fileName, "://") : null;
+ if(protocolSymbol)
+ {
+ char * slash = strstr(protocolSymbol + 3, "/");
+ isURL = true;
+ if(slash)
+ urlFileName = slash;
+ else
+ urlFileName = fileName + strlen(fileName);
+ }
}
- if(strstr(addedPath, "http://") == addedPath)
+
+ protocolSymbol = (addedPath[0] && addedPath[0] != '.' && addedPath[0] != '/' && addedPath[0] != '\\' && addedPath[1] != ':') ? strstr(addedPath, "://") : null;
+ if(protocolSymbol)
{
- strcpy(fileName, "http://");
+ int len = protocolSymbol - addedPath + 3;
+ memcpy(fileName, addedPath, len);
+ fileName[len] = 0;
isURL = true;
- c = 7;
+ c = len;
}
else if(runtimePlatform == win32)
{
import "List"
import "network"
+#ifndef ECERE_NOSSL
+import "SSLSocket"
+#endif
class ConnectionsHolder
{
return string + c;
}
+#ifdef ECERE_NOSSL
private class HTTPConnection : Socket
+#else
+private class HTTPConnection : SSLSocket
+#endif
{
class_no_expansion;
char * server;
int port;
HTTPFile file;
+ bool secure;
processAlone = true;
bool RetrieveHead(char * name, char * referer, char * relocation, bool askBody)
{
bool result = false;
- String http;
+ String http, https;
if(!this || !name) return false;
http = strstr(name, "http://");
if(http != name) http = null;
+ https = http ? null : strstr(name, "https://"); if(https && https != name) https = null;
askedBody = askBody;
delete contentType;
delete contentDisposition;
// ::PrintLn("Opening ", name, " ", (uint64)this, " in thread ", GetCurrentThreadID(), "\n");
- if(this && http)
+ if(this && (http || https))
{
char server[1024];
char msg[1024];
int len;
- char * serverStart = ecere::net::GetString(name, "http://", 0);
+ char * serverStart = http ? ecere::net::GetString(name, "http://", 0) : ecere::net::GetString(name, "https://", 0);
char * fileName = strstr(serverStart, "/");
- int port = 80;
+ int port = https ? 443 : 80;
char * colon;
bool reuse = false;
HTTPConnection connection = null;
if(relocation && !fileName && name[strlen(name)-1] != '/')
{
- strcpy(relocation, "http://");
+ strcpy(relocation, http ? "http://" : "https://");
strcat(relocation, server);
strcat(relocation, "/");
}
connection = null;
for(c : holder.connections)
{
- if(!strcmpi(c.server, server) && c.port == port)
+ if(!strcmpi(c.server, server) && c.port == port && c.secure == (https ? true : false))
{
if(!c.file && c.connected)
{
if(!connection)
{
char ipAddress[1024];
- connection = HTTPConnection { };
+ connection = HTTPConnection
+ {
+#ifndef ECERE_NOSSL
+ autoEstablish = https ? true : false
+#endif
+ };
incref connection; // HTTPFile reference on success
connection.file = this;
connection.server = CopyString(server);
connection.port = port;
+ connection.secure = https ? true : false;
//::PrintLn("Got connectionsMutex for ", name, " ", (uint64)this, " in thread ", GetCurrentThreadID());
holder.connections.Add(connection);
#undef uint
#undef set
-import "ecere"
+#ifdef BUILDING_ECERE_COM
+import "Socket"
+#else
+public import "ecere"
+#endif
/*
static char * pass = "password";
}
*/
-class SSLSocket : Socket
+public class SSLSocket : Socket
{
SSL_CTX *ctx;
SSL *ssl;
result = EARFileSystem::Open(archiveName, archiveFile, mode);
}
#if !defined(ECERE_VANILLA) && !defined(ECERE_NONET)
- else if(strstr(fileName, "http://") == fileName)
+ else if(strstr(fileName, "http://") == fileName || strstr(fileName, "https://"))
{
result = FileOpenURL(fileName);
}
block.bitmap = entry.bitmap;
else
{
- if(path && strstr(path, "http://") == path)
+ if(path && (strstr(path, "http://") == path || strstr(path, "https://") == path))
{
RequestLink request;
objectsMutex.Wait();
// PrintLn("\n\n\nOpening new location: ", location, "\n");
- if(strstr(location, "http://") != location)
+ if(strstr(location, "http://") != location && strstr(location, "https://") != location)
{
if(!FileExists(location))
{