com.despegar.http.client.WithBodyMethod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-java-native-client Show documentation
Show all versions of http-java-native-client Show documentation
HTTP Java client without dependencies
package com.despegar.http.client;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
public abstract class WithBodyMethod extends HttpMethod {
private String body;
public WithBodyMethod(String url, String name, String body) {
super(url, name, true);
this.body = body;
}
@Override
protected void writeBody(HttpURLConnection connection) throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(this.body);
writer.close();
}
}