package com.eactive.eai.adapter.http.client.impl;

import java.nio.charset.Charset;

import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.net.WWWFormCodec;

/**
 * HttpComponent5에서 지원하는 UrlEncodedFormEntity 클래스는 chunked 옵션 설정을 지원하지 않아 새롭게 만들었음.
 */
public class CustomUrlEncodedFormEntity extends StringEntity {

	public CustomUrlEncodedFormEntity(final Iterable<? extends NameValuePair> parameters, final Charset charset,
			final boolean chunked) {
		super(WWWFormCodec.format(parameters,
				charset != null ? charset : ContentType.APPLICATION_FORM_URLENCODED.getCharset()),
				charset != null ? ContentType.APPLICATION_FORM_URLENCODED.withCharset(charset)
						: ContentType.APPLICATION_FORM_URLENCODED,
				chunked);
	}

}
