oVirt / oVirt/ovirt-engine-sdk-java
request new token ,release previous request
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 30
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
method: HttpConnection.send(HttpUriRequest request, boolean failedAuth)
old:
private HttpResponse send(HttpUriRequest request, boolean failedAuth) {
try {
injectHeaders(request);
HttpResponse response = client.execute(request);
/**
* If the request failed because of authentication, and it
* wasn't a request to the SSO service, then the most likely
* cause is an expired SSO token. In this case we need to
* request a new token, and try the original request again, but
* only once. It if fails again, we just return the failed
* response.
*/
if (response.getStatusLine().getStatusCode() == 401 && !failedAuth) {
ssoToken = null;
authenticate();
response = send(request, true);
}
if (response.getFirstHeader("content-type") != null) {
checkContentType(XML_CONTENT_TYPE_RE, "XML", response.getFirstHeader("content-type").getValue());
}
return response;
}
catch (Exception e) {
throw new Error("Failed to send request", e);
}
}
private HttpResponse send(HttpUriRequest request, boolean failedAuth) {
try {
injectHeaders(request);
HttpResponse response = client.execute(request);
/**
* If the request failed because of authentication, and it
* wasn't a request to the SSO service, then the most likely
* cause is an expired SSO token. In this case we need to
* request a new token, and try the original request again, but
* only once. It if fails again, we just return the failed
* response.
*/
if (response.getStatusLine().getStatusCode() == 401 && !failedAuth) {
HttpEntity entity = response.getEntity();
if (null != entity) {
entity.getContent().close();
}
ssoToken = null;
authenticate();
response = send(request, true);
}
if (response.getFirstHeader("content-type") != null) {
checkContentType(XML_CONTENT_TYPE_RE, "XML", response.getFirstHeader("content-type").getValue());
}
return response;
}
catch (Exception e) {
throw new Error("Failed to send request", e);
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in HttpConnection.send(HttpUriRequest request, boolean failedAuth) and compare the old and proposed implementations in the issue. Read how the failed response entity is handled before authenticate() retries the request. Done means the previous response is released before requesting a new token, while the existing retry and content-type checks remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100