Skip to content

some bugs #2

@terrytomas

Description

@terrytomas

#public String post(HttpPost request, String postData) throws PostageAppException {
request.addHeader(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"));
request.addHeader(HttpHeaders.USER_AGENT, this.getUserAgent());

    HttpResponse postResponse;

    try {
    	
    	request.setEntity(new StringEntity(postData));
        postResponse = this.httpClient.execute(request);

        if (postResponse.getStatusLine().getStatusCode() / 100 != 2) {
            throw new PostageAppException("Unable to connect to PostageApp servers for API endpoint " + request.getURI().toString());
        }

        try {
            return IOUtils.toString(postResponse.getEntity().getContent());
        } catch (Exception e) {
            throw new PostageAppException(e.getMessage());
        }
    } catch (Exception e) {
        throw new PostageAppException(e.getMessage());
    } finally {
        if (httpClient != null) {
            request.releaseConnection();
            httpClient.getConnectionManager().closeExpiredConnections();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions