Class: Gcloud::Logging::Entry::HttpRequest
- Inherits:
-
Object
- Object
- Gcloud::Logging::Entry::HttpRequest
- Defined in:
- lib/gcloud/logging/entry/http_request.rb
Overview
Instance Attribute Summary collapse
-
#cache_hit ⇒ Object
Whether an entity was served from cache (with or without validation).
-
#method ⇒ Object
The request method.
-
#referer ⇒ Object
The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
-
#remote_ip ⇒ Object
The IP address (IPv4 or IPv6) of the client that issued the HTTP request.
-
#response_size ⇒ Object
The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
-
#size ⇒ Object
The size of the HTTP request message in bytes, including the request headers and the request body.
-
#status ⇒ Object
The response code indicating the status of response.
-
#url ⇒ Object
The URL.
-
#user_agent ⇒ Object
The user agent sent by the client.
-
#validated ⇒ Object
Whether the response was validated with the origin server before being served from cache.
Class Method Summary collapse
-
.from_grpc(grpc) ⇒ Object
object.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ HttpRequest
constructor
A new instance of HttpRequest.
-
#to_grpc ⇒ Object
Google::Logging::Type::HttpRequest object.
Constructor Details
#initialize ⇒ HttpRequest
Returns a new instance of HttpRequest.
29 30 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 29 def initialize end |
Instance Attribute Details
#cache_hit ⇒ Object
Whether an entity was served from cache (with or without validation). (Boolean)
78 79 80 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 78 def cache_hit @cache_hit end |
#method ⇒ Object
The request method. Examples: ‘“GET”`, `“HEAD”`, `“PUT”`, `“POST”`. (String)
35 36 37 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 35 def method @method end |
#referer ⇒ Object
The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). (String)
73 74 75 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 73 def referer @referer end |
#remote_ip ⇒ Object
The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: ‘“192.168.1.1”`, `“FE80::0202:B3FF:FE1E:8329”`. (String)
67 68 69 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 67 def remote_ip @remote_ip end |
#response_size ⇒ Object
The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body. (Integer)
56 57 58 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 56 def response_size @response_size end |
#size ⇒ Object
The size of the HTTP request message in bytes, including the request headers and the request body. (Integer)
46 47 48 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 46 def size @size end |
#status ⇒ Object
The response code indicating the status of response. Examples: ‘200`, `404`. (Integer)
51 52 53 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 51 def status @status end |
#url ⇒ Object
The URL. The scheme (http, https), the host name, the path and the query portion of the URL that was requested. Example: ‘“example.com/some/info?color=red”`. (String)
41 42 43 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 41 def url @url end |
#user_agent ⇒ Object
The user agent sent by the client. Example: ‘“Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)”`. (String)
61 62 63 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 61 def user_agent @user_agent end |
#validated ⇒ Object
Whether the response was validated with the origin server before being served from cache. This field is only meaningful if ‘cache_hit` is `true`. (Boolean)
84 85 86 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 84 def validated @validated end |
Class Method Details
.from_grpc(grpc) ⇒ Object
object.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 123 def self.from_grpc grpc return new if grpc.nil? new.tap do |h| h.method = grpc.request_method h.url = grpc.request_url h.size = grpc.request_size h.status = grpc.status h.response_size = grpc.response_size h.user_agent = grpc.user_agent h.remote_ip = grpc.remote_ip h.referer = grpc.referer h.cache_hit = grpc.cache_hit h.validated = grpc.validated_with_origin_server end end |
Instance Method Details
#empty? ⇒ Boolean
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 88 def empty? method.nil? && url.nil? && size.nil? && status.nil? && response_size.nil? && user_agent.nil? && remote_ip.nil? && referer.nil? && cache_hit.nil? && validated.nil? end |
#to_grpc ⇒ Object
Google::Logging::Type::HttpRequest object.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gcloud/logging/entry/http_request.rb', line 104 def to_grpc return nil if empty? Google::Logging::Type::HttpRequest.new( request_method: method.to_s, request_url: url.to_s, request_size: size.to_i, status: status.to_i, response_size: response_size.to_i, user_agent: user_agent.to_s, remote_ip: remote_ip.to_s, referer: referer.to_s, cache_hit: !(!cache_hit), validated_with_origin_server: !(!validated) ) end |