MCPcopy Create free account
hub / github.com/acl-dev/acl / build_request

Method build_request

lib_acl_cpp/src/http/http_header.cpp:885–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

883}
884
885bool http_header::build_request(string& buf) const
886{
887 buf.clear();
888
889 if (fixed_) {
890 build_common(buf);
891 buf += "\r\n";
892 return true;
893 }
894
895 if (url_ == NULL || *url_ == 0) {
896 logger_error("url empty");
897 return false;
898 } else {
899 buf.format("%s %s", method_s_, url_);
900 }
901
902 if (!params_.empty()) {
903 bool first_param;
904 if (strchr(url_, '?') == NULL) {
905 buf << '?';
906 first_param = true;
907 } else {
908 first_param = false;
909 }
910 acl::string tmp;
911 std::list<HTTP_PARAM*>::const_iterator it = params_.begin();
912 for (; it != params_.end(); ++it) {
913 if (first_param) {
914 first_param = false;
915 } else {
916 buf += '&';
917 }
918
919 // ��Ҫ�Բ������� URL ����
920
921 tmp.url_encode((*it)->name);
922 buf += tmp.c_str();
923
924 // ��������ֵΪ��ָ��
925 if ((*it)->value == NULL) {
926 continue;
927 }
928
929 buf += '=';
930
931 // ��������ֵΪ�մ�
932 if (*((*it)->value) == 0) {
933 continue;
934 }
935
936 tmp.url_encode((*it)->value);
937 buf += tmp.c_str();
938 }
939 }
940
941 // ����ʹ���û����õ� HTTP Э��汾�ţ�
942 // HTTP/1.1 Ҫ������� Host �ֶΣ���û�� Host �ֶ�ʱ������� HTTP/1.0

Callers 3

send_requestMethod · 0.45
write_headMethod · 0.45
send_requestMethod · 0.45

Calls 8

beginMethod · 0.80
clearMethod · 0.45
formatMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
getNameMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected