-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use HttpResponseException in annotation-processor #45053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a6551c7
to
af2ee68
Compare
API change check API changes are not detected in this pull request. |
af2ee68
to
aea6d50
Compare
String contentType = response.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE); | ||
if ("application/octet-stream".equalsIgnoreCase(contentType)) { | ||
String contentLength = response.getHeaders().getValue(HttpHeaderName.CONTENT_LENGTH); | ||
exceptionMessage.append("(").append(contentLength).append("-byte body)"); | ||
} else if (data == null || data.toBytes().length == 0) { | ||
exceptionMessage.append("(empty body)"); | ||
} else { | ||
exceptionMessage.append('"').append(new String(data.toBytes(), StandardCharsets.UTF_8)).append('"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alzimmermsft I have been considering if we want to port this functionality over from RestProxy, especially where we check the content type and length to determine body length, as well as the exception messages. Should we just let it fall through instead? I think we will still need to check if data is null/empty to avoid decoding it, but for other cases, just let it fall through. Also, do we need custom messaging? It doesn't add much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checks around application/octet-stream
were done as there isn't a good string representation as it's expected to just be a stream of bytes, which could be anything. And there's also a chance the body was drained and ignored on the failure, which could result in errors if we tried to read it (as we don't buffer for octet-stream).
aea6d50
to
b065cf5
Compare
Description
Closes #43728
If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines