Skip to content

Instantly share code, notes, and snippets.

@dhruvilp
Created January 28, 2021 04:38
Show Gist options
  • Select an option

  • Save dhruvilp/83e559229324326729d65171473bcd0b to your computer and use it in GitHub Desktop.

Select an option

Save dhruvilp/83e559229324326729d65171473bcd0b to your computer and use it in GitHub Desktop.
Compressing POST requests in flutter
void sendCompressed() async {
var gzip = GZipCodec();
String jsonToSend = '{"field1":"Some JSON to send to the server."}';
var compressedBody = gzip.encode(jsonToSend.codeUnits);
Map<String, String> headers = {
"Content-Encoding": "gzip",
"Content-Type": "application/json; charset=UTF-8",
};
var response = await http.post(
"https://example.com/api/v1",
headers,
compressedBody );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment