Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
How do I modify the content of an HttpEntity

I've got an HttpResponse with an HttpEntity (all from org.apache.http).

My HttpEntity has some application/json content that I want to modify before sending it forward.

I can read the content as a string with

EntityUtils.toString(response.getEntity());

But how do I store the modified content of my entity back into my response?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Solved using EntityBuilder.

response.setEntity(EntityBuilder.create().setText(newText).setContentType(ContentType.APPLICATION_JSON).build());
over 4 years ago · Santiago Trujillo Denunciar

0

using the toString method is used to 'print' an object. Most of the time, you'll use the toStringmethod for logging. You should rather access the variables you want to read or modify via the getters. For example:

reponse.getEntity().getContentEncoding().getName();
reponse.getEntity().getContentEncoding().getValue()
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda