自己开发的公众号,可以领取淘宝内部优惠券

// We need this to build our post string
var querystring = require('querystring');
var http = require('http');
var fs = require('fs'); function PostCode(codestring) {
// Build the post string from an object
var post_data = querystring.stringify({
'compilation_level' : 'ADVANCED_OPTIMIZATIONS',
'output_format': 'json',
'output_info': 'compiled_code',
'warning_level' : 'QUIET',
'js_code' : codestring
}); // An object of options to indicate where to post to
var post_options = {
host: 'closure-compiler.appspot.com',
port: '80',
path: '/compile',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(post_data)
}
}; // Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
}); // post the data
post_req.write(post_data);
post_req.end(); } // This is an async file read
fs.readFile('LinkedList.js', 'utf-8', function (err, data) {
if (err) {
// If this were just a small part of the application, you would
// want to handle this differently, maybe throwing an exception
// for the caller to handle. Since the file is absolutely essential
// to the program's functionality, we're going to exit with a fatal
// error instead.
console.log("FATAL An error occurred trying to read in the file: " + err);
process.exit(-2);
}
// Make sure there's data before we post it
if(data) {
PostCode(data);
}
else {
console.log("No data to post");
process.exit(-1);
}
});

  

nodejs http post 请求带参数的更多相关文章

  1. httpclient post请求带参数返回数据乱码问题解决

    客户端代码: //带参数的post请求 @Test public void doPostWithParam() throws Exception { CloseableHttpClient httpC ...

  2. perl post 请求带参数

    my $url='https://wenjinbao.winfae.com/business/dispatch_post.do?action=submitAdminLogin';    my $res ...

  3. Java后端发出post请求带参数并接收返回的json

    核心代码: 参数格式: “key1=value1&key2=value2” /*** sendUrl    (远程请求的URL)* param    (远程请求参数)* JSONObject  ...

  4. java get请求带参数报错 java.io.IOException: Server returned HTTP response code: 400 for URL

    解决方案 在使用JAVA发起http请求的时候,经常会遇到这个错误,我们copy请求地址在浏览器中运行的时候又是正常运行的,造成这个错误的原因主要是因为请求的URL中包含空格,这个时候我们要使用URL ...

  5. 【笔记】Asp.Net WebApi对js POST带参数跨域请求的支持方案

    先说下需求:在原来的WebApi项目中增加对js跨域的请求支持,请求方式:以POST为主,webapi路由规则根据原项目需求修改如下: public static void Register(Http ...

  6. 微信小程序之跳转、请求、带参数请求小例子

    wx.request(OBJECT) wx.request发起的是 HTTPS 请求.一个微信小程序,同时只能有5个网络请求连接. 具体参数说明参看微信小程序官方文档-发起请求. 例: //当页面加载 ...

  7. Spring MVC中forward请求转发2种方式(带参数)

    Spring MVC中forward请求转发2种方式(带参数) http://www.51gjie.com/javaweb/956.html  

  8. angular4 get,post请求(带参数,与不带参数)

    一:在app.module.ts引入HttpMoudle import { BrowserModule } from '@angular/platform-browser'; import { Htt ...

  9. httpclient post请求例子(无参数名与带参数名的例子),多线程并发处理

    版本:4.1 带参数名的情况 HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url ...

随机推荐

  1. boostrap ajax表单验证提交

    =============================================================================== 1. 1 <link href=& ...

  2. 【开发技术】java中代码检查checkStyle结果分析

    编写Javadoc代码在Java代码的类.函数.数据成员前中输入/**回车,Eclipse能够自动生成相应的Javadoc代码.可以在后面添加相关的文字说明. Type is missing a ja ...

  3. DALI解码模块

    DALI-MOD2接口模块使用手册 一.概述(联系人:张先生,电话:13923882807,QQ:813267849) 一.概述 欢迎使用本公司的DALI解码模块,该模块支持"DALI第一套 ...

  4. diffMerge安装配置使用

    概述: 在用git进行源代码版本维护的时候,常常会进行各代码版本之前区别的查看,例如在每次提交改动前进行git diff 可以看到源文件代码相对相应版本或是远程仓库的改动情况,如果有冲突还需要进行me ...

  5. ZooKeeper对比Eureka

    刚开始看到Eureka这个单词的时候真心不会念,查了后发现他有一个好听的名字,来,大家一起念 [ jʊ'rikə ] 简介 Eureka本身是Netflix开源的一款提供服务注册和发现的产品,并且提供 ...

  6. JS中数组的常用方法

    首先,在开始前我们先了解一下什么是数组. 1.什么是数组? 数组就是一组数据的集合,其表现形式就是内存中的一段连续的内存地址,数组名称其实就是连续内存地址的首地址.说白了它就是将一堆数据按照一定的顺序 ...

  7. Log4j源码解析--Appender接口解析

    本文转自上善若水的博客,原文出处:http://www.blogjava.net/DLevin/archive/2012/07/10/382676.html.感谢作者的无私的分享. Appender负 ...

  8. Oracl Over函数

    Oracl Over函数 简介 在介绍Over之前, 必须提到开窗函数, 与 聚 合函数一样, 开窗函数也是对行集组进行聚合计算, 但是它不像普通聚合函数那样每组只返回一个值, 开窗函数可以为每组返回 ...

  9. IO (三)

    1 转换流 1.1 InputStreamReader 1.1.1 InputStreamReader简介 InputStreamReader是字节流通向字符流的桥梁.它使用指定的charset读取字 ...

  10. yum升级mysql

    已安装mysql升级 升级mysql到5.6:下载源wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm安装源:rpm ...