package com.alibaba.nacos.common.model;

import com.alibaba.nacos.common.constant.HttpHeaderConsts;
import com.alibaba.nacos.common.http.param.Header;
import com.alibaba.nacos.common.http.param.MediaType;
import com.alibaba.nacos.common.http.param.Query;

import java.util.Map;

/**
 *
 * Represents an HTTP request , consisting of headers and body.
 *
 * @author mai.jh
 * @date 2020/5/23
 */
public class RequestHttpEntity {

    private final Header headers = Header.newInstance();

    private final Query query;

    private Object body;

    public RequestHttpEntity(Header header, Query query) {
        handleHeader(header);
        this.query = query;
    }

    public RequestHttpEntity(Header header, Query query, Object body) {
        handleHeader(header);
        this.query = query;
        this.body = body;
    }

    private void handleHeader(Header header) {
        if (header != null && !header.getHeader().isEmpty()) {
            Map<String, String> headerMap = header.getHeader();
            headers.addAll(headerMap);
        }
    }

    public Header getHeaders() {
        return headers;
    }

    public Query getQuery() {
        return query;
    }

    public Object getBody() {
        return body;
    }

    public boolean isEmptyBody() {
        return body == null;
    }

}

@@ -1,110 +1,628 @@
-package com.alibaba.nacos.common.model;%0A%0Aimport com.alibaba.nacos.common.constant.HttpHeaderConsts;%0Aimport
+/*%0A * Copyright 1999-2018 Alibaba Group Holding Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage
  com
@@ -647,26 +647,15 @@
 mon.
-http.param.Header;
+model;%0A
 %0Aimp
@@ -698,17 +698,14 @@
 ram.
-MediaType
+Header
 ;%0Aim

add class file license.