我正在尝试从请求标头中获取最后修改日期。奇怪的是,当我从邮递员发出请求时,我看到了“ Last-Modified”,但是从Ruby中却没有。
有什么想法吗?
代码如下:
def get_last_date(uri)
http = Net::HTTP.new(uri.host, uri.inferred_port)
http.use_ssl = (uri.scheme == 'https')
http.start
begin
req = Net::HTTP::Head.new(uri.request_uri)
resp = http.request(req)
resp.each_capitalized { |key, value| p " - #{key}: #{value}" }
return DateTime.strptime(resp['Last-Modified'], '%a, %e %b %Y %H:%M:%S')
ensure
http.finish
end
end
这是我在邮递员中看到的东西
这就是我在控制台(即从Ruby)中看到的内容: