Skip to content

Commit f02735d

Browse files
Merge branch 'master' into RemoteAddrFix
2 parents 98e634c + 30ee333 commit f02735d

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

gxmail/src/main/java/com/genexus/internet/SMTPSession.java

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -611,46 +611,44 @@ private String getNextMessage(String sTime, String sPrefix, boolean end)
611611
return "--" + getStartMessage(sTime, sPrefix) + (end?"--":"");
612612
}
613613

614-
private void sendAttachment(String sTime, String fileNamePath, String attachmentPath) throws GXMailException, IOException
615-
{
614+
private void sendAttachment(String sTime, String fileNamePath, String attachmentPath) throws GXMailException, IOException {
616615
InputStream is = null;
617616
String fileName = fileNamePath;
618617
FileInputStream fis = null;
619618

620-
if (fileNamePath.lastIndexOf(File.separator) != -1)
619+
if (fileNamePath.lastIndexOf(File.separator) != -1)
621620
fileName = fileNamePath.substring(fileNamePath.lastIndexOf(File.separator) + 1);
622621

623-
try {
624-
fis = new FileInputStream(attachmentPath + fileNamePath);
625-
is = fis;
626-
}
627-
catch (FileNotFoundException e) {
628-
log ("11 - FileNotFound " + e.getMessage());
622+
try {
623+
fis = new FileInputStream(attachmentPath + fileNamePath);
624+
is = fis;
625+
626+
println(getNextMessageIdMixed(sTime, false));
627+
println("Content-Type: " + "application/octet-stream");
628+
println("Content-Transfer-Encoding: " + "base64");
629+
println("Content-Disposition: " + "attachment; filename=\"" + GXMailer.getEncodedString(fileName) + "\"");
630+
println("");
631+
632+
int BUFFER_SIZE = 4096;
633+
byte[] buffer = new byte[BUFFER_SIZE];
634+
OutputStream base64Output = new Base64OutputStream(outStream);
635+
int n = is.read(buffer, 0, BUFFER_SIZE);
636+
while (n >= 0) {
637+
base64Output.write(buffer, 0, n);
638+
n = is.read(buffer, 0, BUFFER_SIZE);
639+
}
640+
base64Output.flush();
641+
outStream.writeBytes(CRLF);
642+
outStream.flush();
643+
} catch (FileNotFoundException e) {
644+
log("11 - FileNotFound " + e.getMessage());
629645
throw new GXMailException("Can't find " + attachmentPath + fileNamePath, MAIL_InvalidAttachment);
630646
} finally {
631-
if (is != null)
632-
is.close();
633-
if (fis != null)
634-
fis.close();
647+
if (is != null)
648+
is.close();
649+
if (fis != null)
650+
fis.close();
635651
}
636-
637-
println(getNextMessageIdMixed(sTime, false));
638-
println("Content-Type: " + "application/octet-stream");
639-
println("Content-Transfer-Encoding: " + "base64");
640-
println("Content-Disposition: " + "attachment; filename=\"" + GXMailer.getEncodedString(fileName) + "\"");
641-
println("");
642-
643-
int BUFFER_SIZE = 4096;
644-
byte[] buffer = new byte[BUFFER_SIZE];
645-
OutputStream base64Output = new Base64OutputStream(outStream);
646-
int n = is.read(buffer, 0, BUFFER_SIZE);
647-
while (n >= 0) {
648-
base64Output.write(buffer, 0, n);
649-
n = is.read(buffer, 0, BUFFER_SIZE);
650-
}
651-
base64Output.flush();
652-
outStream.writeBytes(CRLF);
653-
outStream.flush();
654652
}
655653

656654
private void println(String s) throws IOException

java/src/main/java/com/genexus/db/driver/GXConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public final class GXConnection extends AbstractGXConnection implements Connecti
8282

8383
//JMX Properties
8484
int numberRequest = 0;
85-
java.util.Date timeLastRequest;
85+
java.util.Date timeLastRequest = new java.util.Date();
8686
String sentenceLastRequest;
8787
String lastObjectExecuted;
8888
boolean finishExecute = true;

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.net.InetAddress;
55
import java.net.URISyntaxException;
66
import java.net.UnknownHostException;
7+
import java.nio.charset.Charset;
78
import java.nio.charset.StandardCharsets;
89
import java.security.KeyManagementException;
910
import java.security.KeyStoreException;
@@ -21,6 +22,7 @@
2122
import org.apache.http.client.config.CookieSpecs;
2223
import org.apache.http.conn.routing.HttpRoute;
2324
import org.apache.http.conn.ssl.NoopHostnameVerifier;
25+
import org.apache.http.entity.ContentType;
2426
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
2527
import org.apache.http.protocol.HttpContext;
2628
import org.apache.http.auth.AuthSchemeProvider;
@@ -723,7 +725,11 @@ public String getString() {
723725
return "";
724726
try {
725727
this.setEntity();
726-
String res = EntityUtils.toString(entity, "UTF-8");
728+
Charset charset = ContentType.getOrDefault(entity).getCharset();
729+
if (charset == null) {
730+
charset = StandardCharsets.UTF_8;
731+
}
732+
String res = EntityUtils.toString(entity, charset);
727733
eof = true;
728734
return res;
729735
} catch (IOException e) {

0 commit comments

Comments
 (0)