contentLength com valor negativo
Ao tentar realizar uma requisição POST estamos recebendo o contentLength com valor negativo -1, não identificando o conteúdo do content. Utilizei como teste o POSTMAN para realizar a requisição para certificar que a URL recebida não se encontra com problema.
Arquivei ao chamado essa requisição e disponibilizo também o método responsável pelo post.
`public String post() throws HttpException { try { mPrintHttpMethod("POST: ".concat(mGetURIComplete()));
URI uri = new URI(url);
DebugUtil.console(mGetURIComplete());
options.httpType = HttpStream.POST;
options.postData = params.toString().concat(deviceInfo);
HttpStream stream = new HttpStream(uri, options);
int statusCode = stream.responseCode;
int sizeContent = stream.contentLength;
String response = "";
try {
if (statusCode == 200) {
if (sizeContent <= 0) {
return response;
}
System.out.println("sizeContent >>>> " + sizeContent);
if (usingSSL) {
response = mGetContentResponseHTTPS(stream);
} else {
response = mGetContentResponseHTTP(stream);
}
}
switch (statusCode) {
case 200:
break;
case 301:
case 302:
throw new HttpException("Não foi possivel acessar o servidor, verifique sua internet e tente novamente.");
case 404:
throw new HttpException("Página não encontrada.");
case 403:
case 401:
throw new HttpException("Acesso negado");
case 500:
throw new HttpException("Falha ao conectar no servidor");
case 502:
case 504:
throw new HttpException("Não foi possível conectar tente novamente.");
case 101:
throw new HttpException("Servidor está demorando para responder, verifique sua internet e tente novamente.");
default:
throw new HttpException(statusCode + "#");
}
} finally {
stream.close();
}
return response;
} catch (IOException exception) {
DebugUtil.console(exception);
throw mGetHttpException(exception);
}
}`