[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class AbstractHttpContent (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.AbstractHttpContent)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.AbstractHttpContent)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.AbstractHttpContent)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.AbstractHttpContent)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.AbstractHttpContent)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.AbstractHttpContent)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.AbstractHttpContent) \n\n public abstract class AbstractHttpContent implements HttpContent\n\nAbstract implementation of an HTTP content with typical options.\n\nImplementation is not thread-safe. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e AbstractHttpContent \n\nImplements\n----------\n\n[HttpContent](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpContent) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### computeLength(HttpContent content)\n\n public static long computeLength(HttpContent content)\n\nReturns the computed content length based using [IOUtils#computeLength(StreamingContent)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.IOUtils#com_google_api_client_util_IOUtils_computeLength_com_google_api_client_util_StreamingContent_)\nor instead `-1` if [HttpContent#retrySupported()](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpContent#com_google_api_client_http_HttpContent_retrySupported__) is `false` because the\nstream must not be read twice.\n\nConstructors\n------------\n\n### AbstractHttpContent(HttpMediaType mediaType)\n\n protected AbstractHttpContent(HttpMediaType mediaType)\n\n### AbstractHttpContent(String mediaType)\n\n protected AbstractHttpContent(String mediaType)\n\nMethods\n-------\n\n### computeLength()\n\n protected long computeLength()\n\nComputes and returns the content length or less than zero if not known.\n\nSubclasses may override, but by default this computes the length by calling [#computeLength(HttpContent)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_computeLength_com_google_api_client_http_HttpContent_).\n\n### getCharset()\n\n protected final Charset getCharset()\n\nReturns the charset specified in the media type or ISO_8859_1 if not specified.\n\n### getLength()\n\n public long getLength()\n\nDefault implementation calls [#computeLength()](/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_computeLength__) once and caches it for future\ninvocations, but subclasses may override.\n\n### getMediaType()\n\n public final HttpMediaType getMediaType()\n\nReturns the media type to use for the Content-Type header, or `null` if unspecified.\n\n### getType()\n\n public String getType()\n\nReturns the content type or `null` for none.\n\n### retrySupported()\n\n public boolean retrySupported()\n\nDefault implementation returns `true`, but subclasses may override.\n\n### setMediaType(HttpMediaType mediaType)\n\n public AbstractHttpContent setMediaType(HttpMediaType mediaType)\n\nSets the media type to use for the Content-Type header, or `null` if unspecified.\n\nThis will also overwrite any previously set parameter of the media type (for example `\n\"charset\"`), and therefore might change other properties as well."]]