ContentTypes.create(ContentTypes.APPLICATION_FORM_URLENCODED, charset.name()));
@Override public THttpResponse send() { String url = buildRequestUrl(); try { initRequest(url); log.debug("Sending '{}' request to '{}'...", method, url); OkTHttpResponse response = new OkTHttpResponse(this, httpClient.newCall(request.build()).execute()); if(log.isDebugEnabled()) { log.debug("Response result : [status={}, content-type='{}', content-length={}]", response.getStatus(), response.getContentType(), response.getContentLength()); MimeType contentType = response.getContentType(); if(null != contentType && ContentTypes.isText(contentType.getMediaType())) { log.debug("Content -> \n{}", Strings.abbreviate(response.getContent(), 200)); } } return response; } catch (Exception e) { throw new HttpException("Error send http request : " + e.getMessage(),e); } }
@Override public THttpResponse send(){ String url = buildRequestUrl(); try { newRequest(url); log.debug("Sending '{}' request to '{}'...", method, url); ApacheTHttpResponse response = new ApacheTHttpResponse(this, request, httpClient.execute(request) ); if(log.isDebugEnabled()) { log.debug("Response result : [status={}, content-type='{}', content-length={}]", response.getStatus(), response.getContentType(), response.getContentLength()); MimeType contentType = response.getContentType(); if(null != contentType && ContentTypes.isText(contentType.toString())) { log.debug("Content -> \n{}", Strings.abbreviate(response.getContent(), 200)); } } return response; } catch (Exception e) { throw new HttpException("Error send http request : " + e.getMessage(),e); }finally{ if(null != request) { request.releaseConnection(); } } }