Merge pull request #1235 from hapifhir/gg-202304-log-fixes

Gg 202304 log fixes
This commit is contained in:
Grahame Grieve 2023-04-28 06:32:28 +10:00 committed by GitHub
commit a5b5d40c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -68,7 +68,7 @@ public class FHIRToolingClient {
//Pass endpoint for client - URI
public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISyntaxException {
preferredResourceFormat = ResourceFormat.RESOURCE_XML;
preferredResourceFormat = ResourceFormat.RESOURCE_JSON;
this.userAgent = userAgent;
initialize(baseServiceUrl);
}

View File

@ -320,10 +320,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
try {
txLog("Connect to "+client.getAddress());
txClient = client;
if (log != null && log.endsWith(".txt")) {
txLog = new TextClientLogger(log);
} else {
if (log != null && (log.endsWith(".htm") || log.endsWith(".html"))) {
txLog = new HTMLClientLogger(log);
} else {
txLog = new TextClientLogger(log);
}
txClient.setLogger(txLog);
txClient.setUserAgent(userAgent);

View File

@ -61,11 +61,11 @@ public class TextClientLogger extends BaseLogger implements ToolingClientLogger
file.println("\r\n--- "+id+" -----------------\r\nRequest: \r\n");
file.println(method+" "+url+" HTTP/1.0");
for (String s : headers)
file.println(Utilities.escapeXml(s));
file.println(s);
if (body != null) {
file.println("");
try {
file.println(Utilities.escapeXml(new String(body, "UTF-8")));
file.println(new String(body, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
}
@ -78,11 +78,11 @@ public class TextClientLogger extends BaseLogger implements ToolingClientLogger
file.println("\r\n\r\nResponse: \r\n");
file.println(outcome);
for (String s : headers)
file.println(Utilities.escapeXml(s));
file.println(s);
if (body != null) {
file.println("");
try {
file.println(Utilities.escapeXml(new String(body, "UTF-8")));
file.println(new String(body, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
}

View File

@ -72,10 +72,11 @@ public class SimpleHTTPClient {
public void checkThrowException() throws IOException {
if (code >= 300) {
String filename = Utilities.path("[tmp]", "fhir-http-"+(++counter)+".log");
String filename = Utilities.path("[tmp]", "http-log", "fhir-http-"+(++counter)+".log");
if (content == null || content.length == 0) {
throw new IOException("Invalid HTTP response "+code+" from "+source+" ("+message+") (no content)");
} else {
Utilities.createDirectory(Utilities.path("[tmp]", "http-log"));
TextFile.bytesToFile(content, filename);
throw new IOException("Invalid HTTP response "+code+" from "+source+" ("+message+") (content in "+filename+")");
}