<commit_before>
#ifdef _JSONCPP_
#include <jsoncpp/json/json.h>
#else
#include <json/json.h>
#endif

#include <boost/asio.hpp>
/*#include <netinet/in.h>*/

#include <cstdio>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
/*#include <syslog.h>*/
#include <stdarg.h>
#include "CService.h"
using namespace boost::asio;

extern "C" void FX_OUTPUT_LOG_FUNC(const char* format, ...)
{
    va_list argList;
    va_start(argList, format);
    FILE* file = fopen("c:/logfile.txt", "a+");
    if (file == NULL) return;
    vfprintf(file, format, argList);
    fprintf(file, "\n");
    fclose(file);
    va_end(argList);

}


#ifdef _CURL_
std::string get_uds_filepath_by_curl(const std::string& host, int port, const std::string& uri, const std::string& getargs)
{


    //std::string filepath;
    //int bGetHtml = 0;
    //int npos = getargs.find("htmlId",0);
    //if( npos >=0 )
    //{
    //    bGetHtml =1 ;
    //}

    //if ( bGetHtml == 1 ) {
    //    filepath =  "{\"success\":true,\"relative_path\":\"/media/rrtd/enter.htm\"}";
    //    /*ngx_str_set(&relative_path, "{\"success\":true,\"relative_path\":\"/media/index.html\"}");*/
    //} else {
    //    filepath = "{\"success\":true,\"relative_path\":\"/media/spring.flv\"}";
    //    /*ngx_str_set(&relative_path, "{\"success\":true,\"relative_path\":\"/media/test.mp4\"}");*/
    //    /*ngx_str_set(&relative_path, "{\"success\":false,\"error_info\":\"flv relative path error. 错误信息\"}");*/
    //}
    //FX_OUTPUT_LOG_FUNC("filepath=%s",filepath.c_str());
    //return filepath;
 

    FX_OUTPUT_LOG_FUNC("get_uds_filepath_by_curl----");
        std::stringstream ss;
        string strurl;
        string strurltmp;
        ss << "http://" << host.c_str() << ":" << port << uri.c_str() << "?" << getargs.c_str(); 
//    	string strurl="http://10.142.51.171:7002/media/media-file-play/0/play?sysCheckNo=3452B1CFFA4080468AF1A64DF7C66255&documentid=090f1b318013f255&versionid=090f1b318013f255_0&type=nginx";
        strurltmp = ss.str();
        int npos = strurltmp.find("HTTP",0);
        if( npos > 0 )
        {
            strurl = strurltmp.substr(0,npos);
        }
        else
        {
            strurl = strurltmp;
        }
        //strurl = strurl.substr(0,strurl.length() - strlen("HTTP/1.1\r\nHost"));
        FX_OUTPUT_LOG_FUNC("url = %s",strurl.c_str());
        Service CService;
        int nRes = CService.HttpRequest("GET",strurl);
        printf("nRes = %d",nRes);
        string strbuf =	CService.m_resp_buffer;
        string strresp = CService.m_resp_header;
        FX_OUTPUT_LOG_FUNC("buf=%s",strbuf.c_str());
        FX_OUTPUT_LOG_FUNC("resp=%s",strresp.c_str());
        return  strbuf;  
}
#endif

std::string get_uds_filepath_by_httpget(const std::string& host, int port, const std::string& uri, const std::string& getargs) {
#ifdef _CURL_
    return get_uds_filepath_by_curl(host, port, uri, getargs);<commit_msg>add FX_outlog<commit_after>
#ifdef _JSONCPP_
#include <jsoncpp/json/json.h>
#else
#include <json/json.h>
#endif

#include <boost/asio.hpp>
/*#include <netinet/in.h>*/
#include <time.h>
#include <cstdio>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
/*#include <syslog.h>*/
#include <stdarg.h>
#include "CService.h"
using namespace boost::asio;

extern "C" void FX_OUTPUT_LOG_FUNC(const char* format, ...)
{
    va_list argList;
    va_start(argList, format);
    FILE* file = fopen("c:/logfile_tmp.txt", "a+");
    if (file == NULL) return;
    time_t   lt;   /*define   a   longint   time   varible*/ 
    lt=time(NULL);/*system   time   and   date*/ 
    fprintf(file,ctime(&lt));
    fprintf(file,"\n");
    vfprintf(file, format, argList);
    fprintf(file, "\n");
    fclose(file);
    va_end(argList);

}


#ifdef _CURL_
std::string get_uds_filepath_by_curl(const std::string& host, int port, const std::string& uri, const std::string& getargs)
{


    //std::string filepath;
    //int bGetHtml = 0;
    //int npos = getargs.find("htmlId",0);
    //if( npos >=0 )
    //{
    //    bGetHtml =1 ;
    //}

    //if ( bGetHtml == 1 ) {
    //    filepath =  "{\"success\":true,\"relative_path\":\"/media/rrtd/enter.htm\"}";
    //    /*ngx_str_set(&relative_path, "{\"success\":true,\"relative_path\":\"/media/index.html\"}");*/
    //} else {
    //    filepath = "{\"success\":true,\"relative_path\":\"/media/spring.flv\"}";
    //    /*ngx_str_set(&relative_path, "{\"success\":true,\"relative_path\":\"/media/test.mp4\"}");*/
    //    /*ngx_str_set(&relative_path, "{\"success\":false,\"error_info\":\"flv relative path error. 错误信息\"}");*/
    //}
    //FX_OUTPUT_LOG_FUNC("filepath=%s",filepath.c_str());
    //return filepath;
 

    FX_OUTPUT_LOG_FUNC("get_uds_filepath_by_curl----");
        std::stringstream ss;
        string strurl;
        string strurltmp;
        ss << "http://" << host.c_str() << ":" << port << uri.c_str() << "?" << getargs.c_str(); 
//    	string strurl="http://10.142.51.171:7002/media/media-file-play/0/play?sysCheckNo=3452B1CFFA4080468AF1A64DF7C66255&documentid=090f1b318013f255&versionid=090f1b318013f255_0&type=nginx";
        strurltmp = ss.str();
        int npos = strurltmp.find("HTTP",0);
        if( npos > 0 )
        {
            strurl = strurltmp.substr(0,npos);
        }
        else
        {
            strurl = strurltmp;
        }
        //strurl = strurl.substr(0,strurl.length() - strlen("HTTP/1.1\r\nHost"));
        FX_OUTPUT_LOG_FUNC("url = %s",strurl.c_str());
        Service CService;
        int nRes = CService.HttpRequest("GET",strurl);
        printf("nRes = %d",nRes);
        string strbuf =	CService.m_resp_buffer;
        string strresp = CService.m_resp_header;
        FX_OUTPUT_LOG_FUNC("nRes=%d",nRes);
        FX_OUTPUT_LOG_FUNC("buf=%s",strbuf.c_str());
        FX_OUTPUT_LOG_FUNC("resp=%s",strresp.c_str());
        return  strbuf;  
}
#endif

std::string get_uds_filepath_by_httpget(const std::string& host, int port, const std::string& uri, const std::string& getargs) {
#ifdef _CURL_
    return get_uds_filepath_by_curl(host, port, uri, getargs);
{'fraction_non_alphanumeric': 0.1891891891891892, 'fraction_numerical': 0.02457002457002457, 'mean_word_length': 3.0197498354180383, 'pattern_counts': {'":': 22, '<': 54, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736533', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2306, 'n_words': 366}