From fb76605985166c4d2172270c8d633ed26d62f698 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Mon, 19 Feb 2024 23:52:47 +0800
Subject: [PATCH 15/26] Replace http-parser dependency with lcr

Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
 CI/dockerfiles/Dockerfile-centos                    | 13 -------------
 CI/dockerfiles/Dockerfile-fedora                    |  1 -
 CI/dockerfiles/Dockerfile-ubuntu                    |  1 -
 CI/pr-gateway.sh                                    |  2 +-
 Dockerfile                                          | 13 -------------
 cmake/checker.cmake                                 |  5 -----
 docs/build_docs/guide/build_guide.md                | 13 -------------
 docs/build_docs/guide/build_guide_with_rpm.md       |  4 +---
 docs/build_docs/guide/build_guide_with_rpm_zh.md    |  4 +---
 docs/build_docs/guide/build_guide_zh.md             | 13 -------------
 .../guide/script/install_iSulad_on_Centos_7.sh      | 11 -----------
 .../script/install_iSulad_on_Ubuntu_20_04_LTS.sh    |  2 +-
 .../isulad_build_in_openeuler.Dockerfile            |  2 +-
 docs/vs_other_engines/vs_docker_command.md          |  1 -
 iSulad.spec                                         |  3 +--
 src/CMakeLists.txt                                  |  1 -
 src/contrib/env_checkconfig                         |  1 -
 .../modules/image/oci/registry/registry_apiv1.c     |  2 +-
 .../modules/image/oci/registry/registry_apiv2.c     |  2 +-
 src/utils/http/CMakeLists.txt                       |  2 +-
 src/utils/http/parser.c                             |  2 +-
 src/utils/http/parser.h                             |  2 +-
 src/utils/http/rest_common.c                        |  2 +-
 23 files changed, 12 insertions(+), 90 deletions(-)

diff --git a/CI/dockerfiles/Dockerfile-centos b/CI/dockerfiles/Dockerfile-centos
index 1d76b4ec..af3ce035 100644
--- a/CI/dockerfiles/Dockerfile-centos
+++ b/CI/dockerfiles/Dockerfile-centos
@@ -207,19 +207,6 @@ RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
 	make install && \
 	ldconfig
 
-# install http-parser
-RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
-	set -x && \
-	cd ~ && \
-	git clone https://gitee.com/src-openeuler/http-parser.git && \
-	cd http-parser && \
-	git checkout -b openEuler-20.03-LTS-tag openEuler-20.03-LTS-tag && \
-	tar -xzvf http-parser-2.9.2.tar.gz && \
-	cd http-parser-2.9.2 && \
-	make -j CFLAGS="-Wno-error" && \
-	make CFLAGS="-Wno-error" install && \
-	ldconfig
-
 # install libwebsockets
 RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
 	set -x && \
diff --git a/CI/dockerfiles/Dockerfile-fedora b/CI/dockerfiles/Dockerfile-fedora
index a105cbb4..be2bf412 100644
--- a/CI/dockerfiles/Dockerfile-fedora
+++ b/CI/dockerfiles/Dockerfile-fedora
@@ -42,7 +42,6 @@ RUN dnf update -y && dnf install -y automake \
 			grpc-plugins \
 			libevent-devel \
 			libwebsockets-devel \
-			http-parser-devel \
 			gtest-devel \
 			gmock-devel \
 			libarchive-devel \
diff --git a/CI/dockerfiles/Dockerfile-ubuntu b/CI/dockerfiles/Dockerfile-ubuntu
index 2441a7ce..09a20eb5 100644
--- a/CI/dockerfiles/Dockerfile-ubuntu
+++ b/CI/dockerfiles/Dockerfile-ubuntu
@@ -71,7 +71,6 @@ RUN apt update -y && apt upgrade -y && \
 			language-pack-en \
 			curl \
 			cmake \
-			libhttp-parser-dev \
 			libprotobuf-dev \
 			libgrpc-dev \
 			libgrpc++-dev \
diff --git a/CI/pr-gateway.sh b/CI/pr-gateway.sh
index e5bf627e..e3613e8e 100755
--- a/CI/pr-gateway.sh
+++ b/CI/pr-gateway.sh
@@ -22,7 +22,7 @@ sed -i "s#http://repo.openeuler.org#https://repo.huaweicloud.com/openeuler#g" /e
 
 dnf update -y
 
-dnf install -y docbook2X doxygen gtest-devel gmock-devel diffutils cmake gcc-c++ yajl-devel patch make libtool libevent-devel libevhtp-devel grpc grpc-plugins grpc-devel protobuf-devel libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel http-parser-devel libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel systemd-devel git chrpath ncurses-devel
+dnf install -y docbook2X doxygen gtest-devel gmock-devel diffutils cmake gcc-c++ yajl-devel patch make libtool libevent-devel libevhtp-devel grpc grpc-plugins grpc-devel protobuf-devel libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel systemd-devel git chrpath ncurses-devel
 if [ $? -ne 0 ]; then
     echo "install dependences failed"
     exit 1
diff --git a/Dockerfile b/Dockerfile
index 3b284630..a30ed12a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -197,19 +197,6 @@ RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
 	make install && \
 	ldconfig
 
-# install http-parser
-RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
-	set -x && \
-	cd ~ && \
-	git clone https://gitee.com/src-openeuler/http-parser.git && \
-	cd http-parser && \
-	git checkout -b openEuler-20.03-LTS-tag openEuler-20.03-LTS-tag && \
-	tar -xzvf http-parser-2.9.2.tar.gz && \
-	cd http-parser-2.9.2 && \
-	make -j CFLAGS="-Wno-error" && \
-	make CFLAGS="-Wno-error" install && \
-	ldconfig
-
 # install libwebsockets
 RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
 	set -x && \
diff --git a/cmake/checker.cmake b/cmake/checker.cmake
index b0c395ef..13f0fd62 100644
--- a/cmake/checker.cmake
+++ b/cmake/checker.cmake
@@ -66,11 +66,6 @@ if (ANDROID OR MUSL)
     _CHECK(CRYPTO_LIBRARY "LIBSSL_LIBRARY-NOTFOUND" "libssl.so")
 endif()
 
-find_path(HTTP_PARSER_INCLUDE_DIR http_parser.h)
-_CHECK(HTTP_PARSER_INCLUDE_DIR "HTTP_PARSER_INCLUDE_DIR-NOTFOUND" "http_parser.h")
-find_library(HTTP_PARSER_LIBRARY http_parser)
-_CHECK(HTTP_PARSER_LIBRARY "HTTP_PARSER_LIBRARY-NOTFOUND" "libhttp_parser.so")
-
 pkg_check_modules(PC_CURL "libcurl>=7.4.0")
 find_path(CURL_INCLUDE_DIR "curl/curl.h"
     HINTS ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS})
diff --git a/docs/build_docs/guide/build_guide.md b/docs/build_docs/guide/build_guide.md
index 741abddd..73a0d9d8 100644
--- a/docs/build_docs/guide/build_guide.md
+++ b/docs/build_docs/guide/build_guide.md
@@ -150,19 +150,6 @@ $ sudo -E make install
 $ sudo -E ldconfig
 ```
 
-#### build and install http-parser
-
-```bash
-$ git clone https://gitee.com/src-openeuler/http-parser.git
-$ cd http-parser
-$ git checkout openEuler-20.03-LTS-tag
-$ tar -xzvf http-parser-2.9.2.tar.gz
-$ cd http-parser-2.9.2
-$ sudo -E make -j CFLAGS="-Wno-error"
-$ sudo -E make CFLAGS="-Wno-error" install
-$ sudo -E ldconfig
-```
-
 #### build and install libwebsockets
 
 ```bash
diff --git a/docs/build_docs/guide/build_guide_with_rpm.md b/docs/build_docs/guide/build_guide_with_rpm.md
index 181b2ef5..acf8e7c0 100644
--- a/docs/build_docs/guide/build_guide_with_rpm.md
+++ b/docs/build_docs/guide/build_guide_with_rpm.md
@@ -29,7 +29,7 @@ BUILD  BUILDROOT  RPMS	SOURCES  SPECS	SRPMS
 
 ```shell
 dnf install -y patch automake autoconf libtool cmake make libcap libcap-devel libselinux libselinux-devel libseccomp libseccomp-devel git libcgroup tar python3 python3-pip  libcurl-devel zlib-devel glibc-headers openssl-devel gcc gcc-c++ systemd-devel systemd-libs golang libtar && \
-dnf --enablerepo=powertools install -y yajl-devel device-mapper-devel http-parser-devel && \
+dnf --enablerepo=powertools install -y yajl-devel device-mapper-devel && \
 dnf install -y epel-release && \
 dnf --enablerepo=powertools install libuv-devel &&\
 dnf install libwebsockets-devel
@@ -281,7 +281,6 @@ rpm -Uvh libarchive-devel-3.4.3-4.x86_64.rpm
 ### 9.1 install iSulad dependencies
 
 ```shell
-dnf --enablerepo=powertools install http-parser-devel
 dnf install -y sqlite-devel
 ```
 
@@ -317,7 +316,6 @@ dnf install libwebsockets-devel
 then, you can install iSulad
 
 ```shell
-dnf --enablerepo=powertools install http-parser-devel
 dnf install -y sqlite-devel.x86_64
 rpm -Uvh iSulad-2.1.0-1.x86_64.rpm
 ```
\ No newline at end of file
diff --git a/docs/build_docs/guide/build_guide_with_rpm_zh.md b/docs/build_docs/guide/build_guide_with_rpm_zh.md
index edb565e3..b9574b4e 100644
--- a/docs/build_docs/guide/build_guide_with_rpm_zh.md
+++ b/docs/build_docs/guide/build_guide_with_rpm_zh.md
@@ -25,7 +25,7 @@ BUILD  BUILDROOT  RPMS	SOURCES  SPECS	SRPMS
 
 ```shell
 dnf install -y patch automake autoconf libtool cmake make libcap libcap-devel libselinux libselinux-devel libseccomp libseccomp-devel git libcgroup tar python3 python3-pip  libcurl-devel zlib-devel glibc-headers openssl-devel gcc gcc-c++ systemd-devel systemd-libs golang libtar && \
-dnf --enablerepo=powertools install -y yajl-devel device-mapper-devel http-parser-devel && \
+dnf --enablerepo=powertools install -y yajl-devel device-mapper-devel && \
 dnf install -y epel-release && \
 dnf --enablerepo=powertools install libuv-devel &&\
 dnf install libwebsockets-devel
@@ -272,7 +272,6 @@ rpm -Uvh libarchive-devel-3.4.3-4.x86_64.rpm
 ### 9.1 安装iSulad的依赖
 
 ```shell
-dnf --enablerepo=powertools install http-parser-devel
 dnf install -y sqlite-devel
 ```
 
@@ -310,7 +309,6 @@ dnf install libwebsockets-devel
 再安装isulad：
 
 ```shell
-dnf --enablerepo=powertools install http-parser-devel
 dnf install -y sqlite-devel.x86_64
 rpm -Uvh iSulad-2.1.0-1.x86_64.rpm
 ```
\ No newline at end of file
diff --git a/docs/build_docs/guide/build_guide_zh.md b/docs/build_docs/guide/build_guide_zh.md
index bfdc69dc..2d853d9c 100644
--- a/docs/build_docs/guide/build_guide_zh.md
+++ b/docs/build_docs/guide/build_guide_zh.md
@@ -150,19 +150,6 @@ $ sudo -E make install
 $ sudo -E ldconfig
 ```
 
-#### 编译安装http-parser
-
-```bash
-$ git clone https://gitee.com/src-openeuler/http-parser.git
-$ cd http-parser
-$ git checkout openEuler-20.03-LTS-tag
-$ tar -xzvf http-parser-2.9.2.tar.gz
-$ cd http-parser-2.9.2
-$ sudo -E make -j CFLAGS="-Wno-error"
-$ sudo -E make CFLAGS="-Wno-error" install
-$ sudo -E ldconfig
-```
-
 #### 编译安装libwebsockets
 
 ```bash
diff --git a/docs/build_docs/guide/script/install_iSulad_on_Centos_7.sh b/docs/build_docs/guide/script/install_iSulad_on_Centos_7.sh
index 3834d333..b268d777 100755
--- a/docs/build_docs/guide/script/install_iSulad_on_Centos_7.sh
+++ b/docs/build_docs/guide/script/install_iSulad_on_Centos_7.sh
@@ -68,17 +68,6 @@ make -j $(nproc)
 make install
 ldconfig
 
-# build http_parser
-cd $BUILD_DIR
-git clone https://gitee.com/src-openeuler/http-parser.git
-cd http-parser
-git checkout openEuler-20.03-LTS-tag
-tar -xzvf http-parser-2.9.2.tar.gz
-cd http-parser-2.9.2
-make -j CFLAGS="-Wno-error"
-make CFLAGS="-Wno-error" install
-ldconfig
-
 # build libwebsockets
 cd $BUILD_DIR
 git clone https://gitee.com/src-openeuler/libwebsockets.git
diff --git a/docs/build_docs/guide/script/install_iSulad_on_Ubuntu_20_04_LTS.sh b/docs/build_docs/guide/script/install_iSulad_on_Ubuntu_20_04_LTS.sh
index 4f27244e..f44bddb4 100755
--- a/docs/build_docs/guide/script/install_iSulad_on_Ubuntu_20_04_LTS.sh
+++ b/docs/build_docs/guide/script/install_iSulad_on_Ubuntu_20_04_LTS.sh
@@ -7,7 +7,7 @@ set -e
 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
 export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
 echo "/usr/local/lib" >> /etc/ld.so.conf
-apt install -y g++ libprotobuf-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev libgrpc-dev libtool automake autoconf cmake make pkg-config libyajl-dev zlib1g-dev libselinux1-dev libseccomp-dev libcap-dev libsystemd-dev git libarchive-dev libcurl4-gnutls-dev openssl libdevmapper-dev python3 libtar0 libtar-dev libhttp-parser-dev libwebsockets-dev
+apt install -y g++ libprotobuf-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev libgrpc-dev libtool automake autoconf cmake make pkg-config libyajl-dev zlib1g-dev libselinux1-dev libseccomp-dev libcap-dev libsystemd-dev git libarchive-dev libcurl4-gnutls-dev openssl libdevmapper-dev python3 libtar0 libtar-dev libwebsockets-dev
 
 BUILD_DIR=/tmp/build_isulad
 
diff --git a/docs/dockerfiles/isulad_build_in_openeuler.Dockerfile b/docs/dockerfiles/isulad_build_in_openeuler.Dockerfile
index 5049f783..a081b009 100644
--- a/docs/dockerfiles/isulad_build_in_openeuler.Dockerfile
+++ b/docs/dockerfiles/isulad_build_in_openeuler.Dockerfile
@@ -26,7 +26,7 @@ RUN dnf install -y rust rust-packaging cargo
 RUN dnf install -y grpc grpc-plugins grpc-devel protobuf-devel libwebsockets libwebsockets-devel
 
 # depends for image module and restful client of iSulad
-RUN dnf install -y libcurl libcurl-devel libarchive-devel http-parser-devel
+RUN dnf install -y libcurl libcurl-devel libarchive-devel
 
 # depends for embedded image of iSulad: -DENABLE_EMBEDDED=ON
 RUN dnf install -y sqlite-devel
diff --git a/docs/vs_other_engines/vs_docker_command.md b/docs/vs_other_engines/vs_docker_command.md
index 5c38d31b..d7b587ea 100644
--- a/docs/vs_other_engines/vs_docker_command.md
+++ b/docs/vs_other_engines/vs_docker_command.md
@@ -114,7 +114,6 @@ Installing dependencies:
  abseil-cpp                  
  clibcni                     
  grpc                   
- http-parser          
  lcr                        
  lib-shim-v2  
  libwebsockets 
diff --git a/iSulad.spec b/iSulad.spec
index eda87f7a..eafa82a0 100644
--- a/iSulad.spec
+++ b/iSulad.spec
@@ -48,7 +48,6 @@ BuildRequires: libisula-devel > %{lcrver_lower} libisula-devel < %{lcrver_upper}
 BuildRequires: cmake gcc-c++ yajl-devel
 BuildRequires: grpc grpc-plugins grpc-devel protobuf-devel
 BuildRequires: libcurl libcurl-devel libarchive-devel device-mapper-devel
-BuildRequires: http-parser-devel
 BuildRequires: libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel
 BuildRequires: systemd-devel git
 BuildRequires: libevhtp-devel libevent-devel
@@ -60,7 +59,7 @@ BuildRequires: lib-shim-v2 lib-shim-v2-devel
 Requires:      libisula > %{lcrver_lower} libisula < %{lcrver_upper}
 Requires:      grpc protobuf
 Requires:      libcurl
-Requires:      http-parser libseccomp
+Requires:      libseccomp
 Requires:      libcap libselinux libwebsockets libarchive device-mapper
 Requires:      systemd
 Requires:      (docker-runc or runc)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d1bc65f9..48c1bad0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,7 +3,6 @@ set(CHECKED_INCLUDE_DIRS
     ${STD_HEADER_SYS_PARAM}
     ${LIBYAJL_INCLUDE_DIR}
     ${LIBARCHIVE_INCLUDE_DIR}
-    ${HTTP_PARSER_INCLUDE_DIR}
     ${OPENSSL_INCLUDE_DIR}
     ${CURL_INCLUDE_DIR}
     ${SYSTEMD_INCLUDE_DIR}
diff --git a/src/contrib/env_checkconfig b/src/contrib/env_checkconfig
index 62a91354..9080e01a 100755
--- a/src/contrib/env_checkconfig
+++ b/src/contrib/env_checkconfig
@@ -164,7 +164,6 @@ config_set CONFIG_SMP && echo -n "Cpuset Cgroup Result: " && config_enable CONFI
 echo ""
 echo "--- Third-party Packages ---"
 echo -n "libyajl: " && has_lib libyajl
-echo -n "libhttp_parser: " && has_lib libhttp_parser
 echo -n "libevhtp.so.1.2.16: " && has_lib libevhtp.so.1.2.16
 echo -n "libseccomp: " && has_lib libseccomp
 echo -n "libcap.so: " && has_lib libcap.so
diff --git a/src/daemon/modules/image/oci/registry/registry_apiv1.c b/src/daemon/modules/image/oci/registry/registry_apiv1.c
index 414eb65c..6da24c1d 100644
--- a/src/daemon/modules/image/oci/registry/registry_apiv1.c
+++ b/src/daemon/modules/image/oci/registry/registry_apiv1.c
@@ -18,7 +18,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
-#include <http_parser.h>
+#include <isula_libutils/http_parser.h>
 #include <isula_libutils/json_common.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/src/daemon/modules/image/oci/registry/registry_apiv2.c b/src/daemon/modules/image/oci/registry/registry_apiv2.c
index 3b3bbd93..dd49fab7 100644
--- a/src/daemon/modules/image/oci/registry/registry_apiv2.c
+++ b/src/daemon/modules/image/oci/registry/registry_apiv2.c
@@ -18,7 +18,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
-#include <http_parser.h>
+#include <isula_libutils/http_parser.h>
 #include <isula_libutils/json_common.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/src/utils/http/CMakeLists.txt b/src/utils/http/CMakeLists.txt
index ad7d0747..23d92cdc 100644
--- a/src/utils/http/CMakeLists.txt
+++ b/src/utils/http/CMakeLists.txt
@@ -20,7 +20,7 @@ target_include_directories(libhttpclient PUBLIC
 
 # set libhttpclient FLAGS
 set_target_properties(libhttpclient PROPERTIES PREFIX "")
-target_link_libraries(libhttpclient ${HTTP_PARSER_LIBRARY} ${CURL_LIBRARY})
+target_link_libraries(libhttpclient ${CURL_LIBRARY})
 
 set_target_properties(libhttpclient PROPERTIES LINKER_LANGUAGE "C")
 
diff --git a/src/utils/http/parser.c b/src/utils/http/parser.c
index cf8425e4..3e910efc 100644
--- a/src/utils/http/parser.c
+++ b/src/utils/http/parser.c
@@ -38,7 +38,7 @@
  */
 
 #include "parser.h"
-#include <http_parser.h>
+#include <isula_libutils/http_parser.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/src/utils/http/parser.h b/src/utils/http/parser.h
index ce5fe5e7..fd8f150d 100644
--- a/src/utils/http/parser.h
+++ b/src/utils/http/parser.h
@@ -42,7 +42,7 @@
 
 #include <stddef.h>
 
-#include "http_parser.h"
+#include <isula_libutils/http_parser.h>
 
 #undef TRUE
 #define TRUE 1
diff --git a/src/utils/http/rest_common.c b/src/utils/http/rest_common.c
index 885375f2..d851ba96 100644
--- a/src/utils/http/rest_common.c
+++ b/src/utils/http/rest_common.c
@@ -16,7 +16,7 @@
 
 #include <dlfcn.h>
 #include <string.h>
-#include <http_parser.h>
+#include <isula_libutils/http_parser.h>
 #include <stdlib.h>
 
 #include "isula_libutils/log.h"
-- 
2.25.1

