调试提示:从客户端获取线路跟踪信息 - 适用于 Ruby 的 Amazon 开发工具包
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

调试提示:从客户端获取线路跟踪信息

您可以从Amazon客户端,方法是设置http_wire_trace选项。此信息有助于区分客户端更改、服务问题和用户错误。以下示例创建了一个启用了线路跟踪的 Amazon S3 客户端。

s3 = Aws::S3::Client.new(http_wire_trace: true)

鉴于以下代码和参数 bucket_name,输出会显示一条消息来表明是否存在该名称的存储桶。

require 'aws-sdk' s3 = Aws::S3::Resource.new(client: Aws::S3::Client.new(http_wire_trace: true)) if s3.bucket(ARGV[0]).exists? puts "Bucket #{ARGV[0]} exists" else puts "Bucket #{ARGV[0]} does not exist" end

如果存储桶存在,则输出类似于以下内容,其中 ACCESS_KEY 是您的访问密钥的值。(为便于阅读,向 HEAD 行添加了回车。)

opening connection to bucket_name.s3-us-west-1.amazonaws.com:443... opened starting SSL for bucket_name.s3-us-west-1.amazonaws.com:443... SSL established <- "HEAD / HTTP/1.1\r\n Content-Type: \r\n Accept-Encoding: \r\n User-Agent: aws-sdk-ruby2/2.2.7 ruby/2.1.7 x64-mingw32\r\n X-Amz-Date: 20160121T191751Z\r\n Host: bucket_name.s3-us-west-1.amazonaws.com\r\n X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\r\n Authorization: AWS4-HMAC-SHA256 Credential=ACCESS_KEY/20160121/us-west-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=2ca8301c5e829700940d3cc3bca2a3e8d79d177f2c046c34a1a285770db63820\r\n Content-Length: 0\r\n Accept: */*\r\n \r\n" -> "HTTP/1.1 301 Moved Permanently\r\n" -> "x-amz-bucket-region: us-west-2\r\n" -> "x-amz-request-id: F3C75F33EF0792C4\r\n" -> "x-amz-id-2: N6BzRLx8b68NmF50g1IxLzT+E4uWPuAIRe7Pl4XKl5STT4tfNO7gBsO8qrrAnG4CbVpU0iIRXmk=\r\n" -> "Content-Type: application/xml\r\n" -> "Transfer-Encoding: chunked\r\n" -> "Date: Thu, 21 Jan 2016 19:17:54 GMT\r\n" -> "Server: AmazonS3\r\n" -> "\r\n" Conn keep-alive Bucket bucket_name exists