httpレスポンスに自作ヘッダーを付与する
小ネタです。
httpレスポンスに自作ヘッダーを付与します。
phpならただ
<?php header('Name: asmsuechan'); ?>
とすればレスポンスのヘッダーにName: asmsuechanを追加できます。ここで注意すべきは、<?php ~ ?>より以前に何か文字を配置しないことです。
herokuでサクっと作って試してみました。https://my-http-response.herokuapp.com/
% ruby http_client.rb HTTP/1.1 200 OK Connection: close Date: Sat, 30 Apr 2016 14:35:19 GMT Server: Apache Name: asmsuechan Content-Length: 0 Content-Type: text/html;charset=UTF-8 Via: 1.1 vegur
Name: asmsuechanが返ってきています。