<commit_before>const http = require('http')
const querystring = require('querystring')

module.exports = (httpOption, param) => {

  return new Promise(function(resolve, reject) {

    //用于存储接收数据的数组    
    let data = []

    //定义返回数据的结构    
    let resContent = {
      'statusCode': '', //状态码
      'message': '', //说明信息
      'content': '' //返回的数据内容
    }

    //设置http请求内容长度    
    httpOption.headers["Content-Length"] = querystring.stringify(param).length

    let reqTimer = null
    let req = null

    // 请求超时则中断
    reqTimer = setTimeout(() => {

      req.abort()

      console.log('\x1B[31m%s\x1B[39m', `${req.path} is request timeout.`)

    }, httpOption.timeOut || 3000)

    //创建http request 请求    
    req = http.request(httpOption, (res) => {

      //建立请求则清除超时
      clearTimeout(reqTimer)

      let statusCode = res.statusCode.toString()

      console.log('\x1B[1m%s\x1B[22m', '[---start---]');
      console.log('\x1B[32m%s\x1b[39m:', `${httpOption.path} statusCode is ${statusCode}`)

      res.on('data', (chunk) => {
        data.push(chunk)
      })

      res.on('end', () => {

        console.log('\x1B[1m%s\x1B[22m', '[---end---]')

        resContent.statusCode = res.statusCode
        resContent.message = res.statusMessage

        if (statusCode.indexOf(4) !== -1 || statusCode.indexOf(5) !== -1) {

          resolve(resContent)

        } else {

          try {

            resContent.content = JSON.parse(data.join('').toString('utf-8'))

            resolve(resContent)

          } catch (error) {

            console.log('\x1B[31m%s\x1B[39m', error)
<commit_msg>update info message<commit_after>const http = require('http')
const querystring = require('querystring')

module.exports = (httpOption, param) => {

  return new Promise(function(resolve, reject) {

    //用于存储接收数据的数组    
    let data = []

    //定义返回数据的结构    
    let resContent = {
      'statusCode': '', //状态码
      'message': '', //说明信息
      'content': '' //返回的数据内容
    }

    //设置http请求内容长度    
    httpOption.headers["Content-Length"] = querystring.stringify(param).length

    let reqTimer = null
    let req = null

    // 请求超时则中断
    reqTimer = setTimeout(() => {

      req.abort()

      console.log('\x1B[31m%s\x1B[39m', `[Timeout]:${httpOption.hostname}${httpOption.path}`)

    }, httpOption.timeOut || 3000)

    //创建http request 请求    
    req = http.request(httpOption, (res) => {

      //建立请求则清除超时
      clearTimeout(reqTimer)

      let statusCode = res.statusCode.toString()

      console.log('\x1B[32m%s\x1b[39m:', `[Success]:${httpOption.hostname}${httpOption.path}`)

      res.on('data', (chunk) => {
        data.push(chunk)
      })

      res.on('end', () => {

        resContent.statusCode = res.statusCode
        resContent.message = res.statusMessage

        if (statusCode.indexOf(4) !== -1 || statusCode.indexOf(5) !== -1) {

          resolve(resContent)

        } else {

          try {

            resContent.content = JSON.parse(data.join('').toString('utf-8'))

            resolve(resContent)

          } catch (error) {

            console.log('\x1B[31m%s\x1B[39m', error)

{'fraction_non_alphanumeric': 0.169594378792718, 'fraction_numerical': 0.020440753752794635, 'mean_word_length': 2.2659019812304484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6371296', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1120, 'n_words': 168}