// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Author: jmarantz@google.com (Joshua Marantz)
// Protobufs to help with http caching

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package net_instaweb;

// NEXT ID: 3
message NameValue {
  required string name = 1;
  required string value = 2;
};

// NEXT ID: 13
message HttpResponseHeaders {
  optional int32 status_code = 1;
  optional string reason_phrase = 2;
  optional int32 minor_version = 3;
  optional int32 major_version = 4 [ default = 1 ];
  optional int64 expiration_time_ms = 5;
  optional int64 date_ms = 6;  // Timestamp from Date header.
  optional int64 last_modified_time_ms = 10;
  optional int64 cache_ttl_ms = 11;
  optional bool cacheable = 7;
  optional bool proxy_cacheable = 8;
  repeated NameValue header = 9;
  optional bool is_implicitly_cacheable = 12;
};

// Contains everything in HttpRequest except url itself.
// The name HttpRequestHeaders is a misnomer.
// NEXT ID: 6
message HttpRequestHeaders {

  // NEXT ID: 11
  enum Method {
    OPTIONS = 1;
    GET = 2;
    HEAD = 3;
    POST = 4;
    PUT = 5;
    DELETE = 6;
    TRACE = 7;
    CONNECT = 8;
    INVALID = 9;  // Originally ERROR, but that is a macro in C++.
    PATCH = 10;
  };

  // Note: the URL is not part of this protobuf, as it's typically kept
  // outside the context of the header structure (e.g. a formal arg to
  // a Fetch function or the key to a cache).

  optional int32 minor_version = 1;
  optional int32 major_version = 2 [ default = 1 ];
  optional Method method = 3 [ default = GET ];
  repeated NameValue header = 4;

  // RFC 2616 sec 4.3 (encoded message body)
  optional bytes message_body = 5;
};
