2016-05-07 5 views
0

私は、Post要求がNode.jsに送信され、同じ要求本体を持つhttps restエンドポイントに送信され、応答を返さなければならないという要件があります。私はHttp、node-rest-client npmsを使ってみました。これらはすべてHTTP POST要求では動作しますが、httpsでは動作しません。コードの助けを借りれば偉大になります。node.jsを使用してhttps restエンドに投稿する

ありがとうございます。

答えて

2

node-rest-clientは実際にドキュメントごとにHTTPS要求をサポートしています。 443ポートまたはクライアントを初期化するときconnectionオプションを追加します:あなたは指定する必要があり

var options = { 
    // proxy configuration 
    proxy: { 
     host: "proxy.foo.com", // proxy host 
     port: 8080, // proxy port 
     user: "ellen", // proxy username if required 
     password: "ripley" // proxy pass if required 
    }, 
    // aditional connection options passed to node http.request y https.request methods 
    // (ie: options to connect to IIS with SSL) 
    connection: { 
     secureOptions: constants.SSL_OP_NO_TLSv1_2, 
     ciphers: 'ECDHE-RSA-AES256-SHA:AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM', 
     honorCipherOrder: true 
    }, 
    // customize mime types for json or xml connections 
    mimetypes: { 
     json: ["application/json", "application/json;charset=utf-8"], 
     xml: ["application/xml", "application/xml;charset=utf-8"] 
    }, 
    user: "admin", // basic http auth username if required 
    password: "123", // basic http auth password if required 
    requestConfig: { 
     timeout: 1000, //request timeout in milliseconds 
     noDelay: true, //Enable/disable the Nagle algorithm 
     keepAlive: true, //Enable/disable keep-alive functionalityidle socket. 
     keepAliveDelay: 1000 //and optionally set the initial delay before the first keepalive probe is sent 
    }, 
    responseConfig: { 
     timeout: 1000 //response timeout 
    } 
}; 

詳細はhttps://github.com/aacerox/node-rest-clientを参照してください。

+0

「リクエスト」はまた、この種のもののための優れたモジュールでもあり、httpsもサポートしています – Paul

関連する問題