Added file download support to EcpWebService, fixed a bug with non-au…#341
Merged
Added file download support to EcpWebService, fixed a bug with non-au…#341
Conversation
…thenticated calls to proxyGet fieldcapture#3715
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for streaming (file download) responses from upstream services in EcpWebService, and addresses an unauthenticated-call bug related to request header handling.
Changes:
- Added
readToStream(...)to stream HTTP responses to a caller-providedOutputStream(intended for file downloads). - Updated timeout handling in
getStringto useHttpStatus.SC_GATEWAY_TIMEOUT. - Fixed a null-user bug in multipart POST header setup by only reading
user.userIdwhen a user is present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
grails-app/services/au/org/ala/ecodata/forms/EcpWebService.groovy
Outdated
Show resolved
Hide resolved
grails-app/services/au/org/ala/ecodata/forms/EcpWebService.groovy
Outdated
Show resolved
Hide resolved
grails-app/services/au/org/ala/ecodata/forms/EcpWebService.groovy
Outdated
Show resolved
Hide resolved
| } catch (Exception e) { | ||
| resp = [error: "Timed out calling web service. URL= ${url}.", statusCode: conn?.responseCode?:""] | ||
|
|
||
| log.error "Failed calling web service. ${e.getClass()} ${e.getMessage()} URL= ${url}.", e |
Collaborator
Author
There was a problem hiding this comment.
Calling disconnect is only recommended if more calls to the server are not anticipated. Almost all requests are to ecodata and we don't want to close the socket here.
Comment on lines
+109
to
+124
| try (InputStream inputStream = conn.inputStream) { | ||
| outputStream << inputStream | ||
| } | ||
| resp = [statusCode: conn.responseCode] | ||
|
|
||
| } catch (SocketTimeoutException e) { | ||
| resp = [error: "Timed out calling web service. URL= ${url}.", statusCode: conn?.responseCode?:""] | ||
| log.error "Timed out calling web service. URL= ${url}.", e | ||
| } catch (SocketException se) { | ||
| resp = [error: "Timed out calling web service. URL= ${url}.", statusCode: conn?.responseCode?:""] | ||
|
|
||
| log.warn "Socket connection closed. ${se.getMessage()} URL= ${url}.", se | ||
| } catch (Exception e) { | ||
| resp = [error: "Timed out calling web service. URL= ${url}.", statusCode: conn?.responseCode?:""] | ||
|
|
||
| log.error "Failed calling web service. ${e.getClass()} ${e.getMessage()} URL= ${url}.", e |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
temi
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…thenticated calls to proxyGet fieldcapture#3715