Package org.eclipse.sw360.http
Interface RequestBodyBuilder
-
public interface RequestBodyBuilderA builder interface for defining the body of a request.
This interface provides several methods for defining a request body with different content. It is used for both regular request bodies and the bodies of the parts of a multipart request. An implementation is passed to a consumer which then invokes the desired method to set the body. Note that the methods are mutually exclusive; a concrete builder instance will allow only a single method call.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidfile(Path path, String mediaType)Sets the request body as a file.voidjson(Object payload)Sets the request body as an object that is serialized to JSON.voidstring(String body, String mediaType)Sets the request body as a string.
-
-
-
Method Detail
-
string
void string(String body, String mediaType)
Sets the request body as a string. Based on the media type, the content header is set.- Parameters:
body- the request body as stringmediaType- the media type of the content
-
file
void file(Path path, String mediaType)
Sets the request body as a file. This can be used to upload files to a server. Based on the media type, the content header is set.- Parameters:
path- the path to the file to be uploadedmediaType- the media type of the content
-
json
void json(Object payload)
Sets the request body as an object that is serialized to JSON. This method uses an internal JSON object mapper to generate a JSON representation from the object passed in. It also automatically sets a correctContent-Typeheader.- Parameters:
payload- the object to be used as request payload
-
-