Firstly I just want to say thanks for releasing such a great tool on the Internet!
I have found an issue where the "Generate filename automatically" doesn't work some times, through a process of troubleshooting I determined it was for HTTP/HTTPS downloads greater than 2GB.
I have confirmed the bug exists in FDM 3.9.0 and FDM 3.9.1 Beta build 1268.
I suspect from the subject you will have a pretty good idea where the issue is.
I took a look at the latest source I could find - (on a side note I found the source pretty involved to get going without any guiding notes/documentation not to mention using old/specific library versions - don't get me wrong, it is great you release the source! If you provided 1 page of notes listing the libraries and versions used (download locations a bonus) that would have have saved me hours).
I eventually got it going well enough to identify the cause and a hackish fix to confirm I was on the right track.
Overall my build was not stable with its intergration with Firefox (I believe I was using the wrong libraries - ultimately I don't have enough free time to get a build environment going further so will provide where I got to.
In short the issue is two different modules of code is used for http downloads.
If the file turns out to be larger than 2GB, it hands over to InetFile/fsInternetFile2.cpp.
The v2 file doesn't extract the filename from the "content-disposition" header to populate the m_strSuggFileName variable.
My initial hack I did to prove I was onto a working solution, was adding code into the v2 code that would use the v1 m_strSuggFileName variable if the v2 m_strSuggFileName was NULL.
I started on a cleaner patch into a clean install (trying to get libraries sorted etc), I don't believe I finished, but include what I started on below (which is basically stealing some of your code from v1 and putting it into v2 - from memory it doesn't fully work because you need to get access to the raw headers to get access to the "content-disposition") - then again I could be wrong it may work perfectly, this was months ago!
Hopefully the above notes expedite a solution in the main product.
Thanks again for a developing such as great product,
- M
Code:
Index: InetFile/fsInternetFile2.cpp
===================================================================
--- InetFile/fsInternetFile2.cpp (revision 39)
+++ InetFile/fsInternetFile2.cpp (working copy)
@@ -85,6 +85,81 @@
m_bDoPause = TRUE;
}
+void fsInternetFile2::RetreiveSuggFileName()
+{
+ m_strSuggFileName = "";
+
+ char sz [MAX_PATH];
+ char szFile [MAX_PATH];
+ DWORD dwFL = MAX_PATH;
+
+ // pull out the content-disposition line from m_strHttpHeader
+ LPCSTR psz = fsStrStrNoCase (m_strHttpHeader, "content-disposition");
+ if (psz == NULL)
+ return;
+
+
+// if (FALSE == HttpQueryInfo (m_hFile, HTTP_QUERY_CONTENT_DISPOSITION, sz, &dwFL, NULL))
+// return;
+
+
+ LPCSTR psz = fsStrStrNoCase (sz, "filename");
+ if (psz == NULL)
+ return;
+
+ psz += 8;
+ while (*psz == ' ')
+ psz++;
+ bool bCharset = false;
+ if (*psz == '*')
+ {
+ bCharset = true;
+ psz++;
+ }
+
+ if (*psz++ != '=')
+ return;
+ while (*psz == ' ') psz++;
+
+ BOOL bInvComms = FALSE;
+ if (*psz == '"' || *psz == '\'')
+ {
+ bInvComms = TRUE;
+ psz++;
+ }
+
+ LPSTR pszFile = szFile;
+
+ while (*psz != ';' && *psz != 0)
+ *pszFile++ = *psz++;
+
+ if (bInvComms)
+ *(pszFile-1) = 0;
+ else
+ *pszFile = 0;
+
+ if (bCharset)
+ {
+ LPCSTR psz = strstr (szFile, "''");
+ if (psz != NULL)
+ {
+ if (strnicmp (szFile, "utf-8", 5) == 0)
+ {
+ wchar_t wsz [MAX_PATH];
+ MultiByteToWideChar (CP_UTF8, 0, psz+2, -1, wsz, MAX_PATH);
+ WideCharToMultiByte (CP_ACP, 0, wsz, -1, szFile, MAX_PATH, "_", NULL);
+ }
+ else
+ {
+ lstrcpy (szFile, psz+2);
+ }
+ }
+ }
+
+ m_strSuggFileName = szFile;
+}
+
+
fsInternetResult fsInternetFile2::StartDownloading()
{
if (m_bDownloading == false)
@@ -115,6 +190,11 @@
if (m_strHttpHeader.IsEmpty () == FALSE)
Dialog (IFDD_FROMSERVER, m_strHttpHeader);
+ if (m_strHttpHeader.IsEmpty () == FALSE){
+ // MG HACK to get the suggested filename filename from the header
+ RetreiveSuggFileName();
+ }
+
return m_irLastError;
}
Firstly I just want to say thanks for releasing such a great tool on the Internet!
I have found an issue where the "Generate filename automatically" doesn't work some times, through a process of troubleshooting I determined it was for HTTP/HTTPS downloads greater than 2GB.
I have confirmed the bug exists in FDM 3.9.0 and FDM 3.9.1 Beta build 1268.
I suspect from the subject you will have a pretty good idea where the issue is.
I took a look at the latest source I could find - (on a side note I found the source pretty involved to get going without any guiding notes/documentation not to mention using old/specific library versions - don't get me wrong, it is great you release the source! If you provided 1 page of notes listing the libraries and versions used (download locations a bonus) that would have have saved me hours).
I eventually got it going well enough to identify the cause and a hackish fix to confirm I was on the right track.
Overall my build was not stable with its intergration with Firefox (I believe I was using the wrong libraries - ultimately I don't have enough free time to get a build environment going further so will provide where I got to.
In short the issue is two different modules of code is used for http downloads.
If the file turns out to be larger than 2GB, it hands over to InetFile/fsInternetFile2.cpp.
The v2 file doesn't extract the filename from the "content-disposition" header to populate the m_strSuggFileName variable.
My initial hack I did to prove I was onto a working solution, was adding code into the v2 code that would use the v1 m_strSuggFileName variable if the v2 m_strSuggFileName was NULL.
I started on a cleaner patch into a clean install (trying to get libraries sorted etc), I don't believe I finished, but include what I started on below (which is basically stealing some of your code from v1 and putting it into v2 - from memory it doesn't fully work because you need to get access to the raw headers to get access to the "content-disposition") - then again I could be wrong it may work perfectly, this was months ago!
Hopefully the above notes expedite a solution in the main product.
Thanks again for a developing such as great product,
- M
[code]
Index: InetFile/fsInternetFile2.cpp
===================================================================
--- InetFile/fsInternetFile2.cpp (revision 39)
+++ InetFile/fsInternetFile2.cpp (working copy)
@@ -85,6 +85,81 @@
m_bDoPause = TRUE;
}
+void fsInternetFile2::RetreiveSuggFileName()
+{
+ m_strSuggFileName = "";
+
+ char sz [MAX_PATH];
+ char szFile [MAX_PATH];
+ DWORD dwFL = MAX_PATH;
+
+ // pull out the content-disposition line from m_strHttpHeader
+ LPCSTR psz = fsStrStrNoCase (m_strHttpHeader, "content-disposition");
+ if (psz == NULL)
+ return;
+
+
+// if (FALSE == HttpQueryInfo (m_hFile, HTTP_QUERY_CONTENT_DISPOSITION, sz, &dwFL, NULL))
+// return;
+
+
+ LPCSTR psz = fsStrStrNoCase (sz, "filename");
+ if (psz == NULL)
+ return;
+
+ psz += 8;
+ while (*psz == ' ')
+ psz++;
+ bool bCharset = false;
+ if (*psz == '*')
+ {
+ bCharset = true;
+ psz++;
+ }
+
+ if (*psz++ != '=')
+ return;
+ while (*psz == ' ') psz++;
+
+ BOOL bInvComms = FALSE;
+ if (*psz == '"' || *psz == '\'')
+ {
+ bInvComms = TRUE;
+ psz++;
+ }
+
+ LPSTR pszFile = szFile;
+
+ while (*psz != ';' && *psz != 0)
+ *pszFile++ = *psz++;
+
+ if (bInvComms)
+ *(pszFile-1) = 0;
+ else
+ *pszFile = 0;
+
+ if (bCharset)
+ {
+ LPCSTR psz = strstr (szFile, "''");
+ if (psz != NULL)
+ {
+ if (strnicmp (szFile, "utf-8", 5) == 0)
+ {
+ wchar_t wsz [MAX_PATH];
+ MultiByteToWideChar (CP_UTF8, 0, psz+2, -1, wsz, MAX_PATH);
+ WideCharToMultiByte (CP_ACP, 0, wsz, -1, szFile, MAX_PATH, "_", NULL);
+ }
+ else
+ {
+ lstrcpy (szFile, psz+2);
+ }
+ }
+ }
+
+ m_strSuggFileName = szFile;
+}
+
+
fsInternetResult fsInternetFile2::StartDownloading()
{
if (m_bDownloading == false)
@@ -115,6 +190,11 @@
if (m_strHttpHeader.IsEmpty () == FALSE)
Dialog (IFDD_FROMSERVER, m_strHttpHeader);
+ if (m_strHttpHeader.IsEmpty () == FALSE){
+ // MG HACK to get the suggested filename filename from the header
+ RetreiveSuggFileName();
+ }
+
return m_irLastError;
}
[/code]