package com.hotwj.platform.integration.ocr.baidu;

import cn.hutool.http.ContentType;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import org.springframework.stereotype.Component;

@Component
public class DefaultBaiduOcrHttpClient implements BaiduOcrHttpClient {
    @Override
    public BaiduOcrHttpResponse postForm(String url, String body, int timeoutMs) {
        HttpResponse response = HttpRequest.post(url)
                .header(Header.CONTENT_TYPE, ContentType.FORM_URLENCODED.getValue())
                .body(body)
                .timeout(timeoutMs)
                .execute();
        return new BaiduOcrHttpResponse(response.getStatus(), response.body());
    }
}
