Search in sources :

Example 1 with SupportFormUrlEncoded

use of com.dtflys.forest.http.body.SupportFormUrlEncoded in project forest by dromara.

the class DefaultFormConvertor method encodeRequestBody.

@Override
public byte[] encodeRequestBody(ForestBody body, Charset charset) {
    List<RequestNameValue> nameValueList = new LinkedList<>();
    if (charset == null) {
        charset = StandardCharsets.UTF_8;
    }
    for (ForestRequestBody bodyItem : body) {
        if (bodyItem instanceof SupportFormUrlEncoded) {
            nameValueList.addAll(((SupportFormUrlEncoded) bodyItem).getNameValueList(configuration));
        }
    }
    nameValueList = processFromNameValueList(nameValueList, configuration);
    String strBody = formUrlEncodedString(nameValueList, charset);
    byte[] bytes = strBody.getBytes(charset);
    return bytes;
}
Also used : ForestRequestBody(com.dtflys.forest.http.ForestRequestBody) RequestNameValue(com.dtflys.forest.utils.RequestNameValue) SupportFormUrlEncoded(com.dtflys.forest.http.body.SupportFormUrlEncoded) LinkedList(java.util.LinkedList)

Aggregations

ForestRequestBody (com.dtflys.forest.http.ForestRequestBody)1 SupportFormUrlEncoded (com.dtflys.forest.http.body.SupportFormUrlEncoded)1 RequestNameValue (com.dtflys.forest.utils.RequestNameValue)1 LinkedList (java.util.LinkedList)1