~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/http/HttpTransact.h

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-05-09 01:00:04 UTC
  • mto: (1.1.11) (5.3.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20130509010004-9fqq9n0adseg3f8w
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "congest/Congestion.h"
47
47
 
48
48
#define MAX_DNS_LOOKUPS 2
49
 
#define WUTS_PROXY_ID 0
50
49
#define NUM_SECONDS_IN_ONE_YEAR (31536000)      // (365L * 24L * 3600L)
51
50
 
52
51
#define HTTP_RELEASE_ASSERT(X) ink_release_assert(X)
106
105
#include "InkErrno.h"
107
106
#define UNKNOWN_INTERNAL_ERROR           (INK_START_ERRNO - 1)
108
107
 
109
 
 
110
 
/* WUTS proxy-status codes */
111
 
enum WUTSProxyStatusCode
112
 
{
113
 
  WUTS_PROXY_STATUS_UNKNOWN = 0,
114
 
  WUTS_PROXY_STATUS_UNSPECIFIED = 0,
115
 
  WUTS_PROXY_STATUS_CONTINUE = 100,
116
 
  WUTS_PROXY_STATUS_SWITCHING_PROTOCOL = 101,
117
 
  WUTS_PROXY_STATUS_OK = 200,
118
 
  WUTS_PROXY_STATUS_CREATED = 201,
119
 
  WUTS_PROXY_STATUS_ACCEPTED = 202,
120
 
  WUTS_PROXY_STATUS_NON_AUTHORITATIVE_INFORMATION = 203,
121
 
  WUTS_PROXY_STATUS_NO_CONTENT = 204,
122
 
  WUTS_PROXY_STATUS_RESET_CONTENT = 205,
123
 
  WUTS_PROXY_STATUS_PARTIAL_CONTENT = 206,
124
 
  WUTS_PROXY_STATUS_MULTIPLE_CHOICES = 300,
125
 
  WUTS_PROXY_STATUS_MOVED_PERMANENTLY = 301,
126
 
  WUTS_PROXY_STATUS_MOVED_TEMPORARILY = 302,
127
 
  WUTS_PROXY_STATUS_SEE_OTHER = 303,
128
 
  WUTS_PROXY_STATUS_NOT_MODIFIED = 304,
129
 
  WUTS_PROXY_STATUS_USE_PROXY = 305,
130
 
  WUTS_PROXY_STATUS_BAD_REQUEST = 400,
131
 
  WUTS_PROXY_STATUS_UNAUTHORIZED = 401,
132
 
  WUTS_PROXY_STATUS_PAYMENT_REQUIRED = 402,
133
 
  WUTS_PROXY_STATUS_FORBIDDEN = 403,
134
 
  WUTS_PROXY_STATUS_NOT_FOUND = 404,
135
 
  WUTS_PROXY_STATUS_METHOD_NOT_ALLOWED = 405,
136
 
  WUTS_PROXY_STATUS_NOT_ACCEPTABLE = 406,
137
 
  WUTS_PROXY_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,
138
 
  WUTS_PROXY_STATUS_REQUEST_TIMEOUT = 408,
139
 
  WUTS_PROXY_STATUS_CONFLICT = 409,
140
 
  WUTS_PROXY_STATUS_GONE = 410,
141
 
  WUTS_PROXY_STATUS_LENGTH_REQUIRED = 411,
142
 
  WUTS_PROXY_STATUS_PRECONDITION_FAILED = 412,
143
 
  WUTS_PROXY_STATUS_REQUEST_ENTITY_TOO_LARGE = 413,
144
 
  WUTS_PROXY_STATUS_REQUEST_URI_TOO_LONG = 414,
145
 
  WUTS_PROXY_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
146
 
  WUTS_PROXY_STATUS_INTERNAL_SERVER_ERROR = 500,
147
 
  WUTS_PROXY_STATUS_NOT_IMPLEMENTED = 501,
148
 
  WUTS_PROXY_STATUS_BAD_GATEWAY = 502,
149
 
  WUTS_PROXY_STATUS_SERVICE_UNAVAILABLE = 503,
150
 
  WUTS_PROXY_STATUS_GATEWAY_TIMEOUT = 504,
151
 
  WUTS_PROXY_STATUS_HTTPVER_NOT_SUPPORTED = 505,
152
 
  WUTS_PROXY_STATUS_NO_HTTP_CODE_IN_RESPONSE_LINE = 600,
153
 
  WUTS_PROXY_STATUS_READ_TIMEOUT = 800,
154
 
  WUTS_PROXY_STATUS_LIFETIME_EXPIRED = 801,
155
 
  WUTS_PROXY_STATUS_NO_CLIENT_BIG_OBJECT = 802,
156
 
  WUTS_PROXY_STATUS_SOCKET_READ_ERROR = 803,
157
 
  WUTS_PROXY_STATUS_CLIENT_ABORT = 804,
158
 
  WUTS_PROXY_STATUS_CONNECT_FAILED = 805,
159
 
  WUTS_PROXY_STATUS_INVALID_REQUEST = 806,
160
 
  WUTS_PROXY_STATUS_UNSUPPORTED_REQUEST = 807,
161
 
  WUTS_PROXY_STATUS_INVALID_URL = 808,
162
 
  WUTS_PROXY_STATUS_NO_FILE_DESCRIPTORS = 809,
163
 
  WUTS_PROXY_STATUS_DNS_LOOKUP_FAILURE = 810,
164
 
  WUTS_PROXY_STATUS_PROTOCOL_OR_METHOD_NOT_SUPPORTED = 811,
165
 
  WUTS_PROXY_STATUS_UNABLE_TO_FETCH = 812,
166
 
  WUTS_PROXY_STATUS_NO_RELAY = 813,
167
 
  WUTS_PROXY_STATUS_DISK_IO_ERROR = 814,
168
 
  WUTS_PROXY_STATUS_ZERO_SIZE_OBJECT = 815,
169
 
  WUTS_PROXY_STATUS_PROXY_AUTHORIZATION_FAILURE = 817,
170
 
  WUTS_PROXY_STATUS_WEBFETCH_DETECTED_ERROR = 818,
171
 
  WUTS_PROXY_STATUS_PERSISTENT_READ_ERROR = 819,
172
 
  WUTS_PROXY_STATUS_SPIDER_MEMBER_ABORTED = 820,
173
 
  WUTS_PROXY_STATUS_SPIDER_PARENT_CONTROL_RESTRICTION = 821,
174
 
  WUTS_PROXY_STATUS_SPIDER_UNSUPPORTED_HTTP_VERSION = 822,
175
 
  WUTS_PROXY_STATUS_SPIDER_USER_IDENTIFICATION_FAILURE = 823,
176
 
  WUTS_PROXY_STATUS_SPIDER_RESERVED_FOR_FUTURE_USE_1 = 824,
177
 
  WUTS_PROXY_STATUS_SPIDER_TIMEOUT_WHILE_PASSING = 825,
178
 
  WUTS_PROXY_STATUS_SPIDER_TIMEOUT_WHILE_DRAINING = 826,
179
 
  WUTS_PROXY_STATUS_SPIDER_GENERAL_TIMEOUT = 827,
180
 
  WUTS_PROXY_STATUS_SPIDER_CONNECTION_FAILED = 828,
181
 
  WUTS_PROXY_STATUS_SPIDER_RESERVED_FOR_FUTURE_USE_2 = 829,
182
 
  WUTS_PROXY_STATUS_SPIDER_NO_RESOURCES = 830,
183
 
  WUTS_PROXY_STATUS_SPIDER_INTERNAL_ERROR = 831,
184
 
  WUTS_PROXY_STATUS_SPIDER_INTERNAL_IO_ERROR = 832,
185
 
  WUTS_PROXY_STATUS_SPIDER_DNS_TEMP_ERROR = 833,
186
 
  WUTS_PROXY_STATUS_SPIDER_DNS_HOST_NOT_FOUND = 834,
187
 
  WUTS_PROXY_STATUS_SPIDER_DNS_NO_ADDRESS = 835,
188
 
  WUTS_PROXY_STATUS_SPIDER_RESERVED_FOR_FUTURE_USE_3 = 836,
189
 
  WUTS_PROXY_STATUS_IMS_RECEIVED_CACHE_HIT = 998,
190
 
  WUTS_PROXY_STATUS_GET_RECEIVED_CACHE_HIT = 999,
191
 
  WUTS_PROXY_STATUS_INVALID_ASSIGNED_CODE = 9
192
 
};
193
 
 
194
 
/* WUTS proxy-id */
195
 
typedef int WUTSProxyId;
196
 
 
197
108
enum ViaStringIndex_t
198
109
{
199
110
  //
655
566
    RANGE_REQUESTED,
656
567
    RANGE_NOT_SATISFIABLE,
657
568
    RANGE_NOT_HANDLED,
 
569
    RANGE_NOT_TRANSFORM_REQUESTED
658
570
  };
659
571
  
660
572
  enum CacheAuth_t
834
746
  typedef struct _DNSLookupInfo
835
747
  {
836
748
    int attempts;
 
749
    /** Origin server address source selection.
 
750
 
 
751
        If config says to use CTA (client target addr) state is
 
752
        OS_ADDR_TRY_CLIENT, otherwise it remains the default. If the
 
753
        connect fails then we switch to a USE. We go to USE_HOSTDB if
 
754
        (1) the HostDB lookup is successful and (2) some address other
 
755
        than the CTA is available to try. Otherwise we keep retrying
 
756
        on the CTA (USE_CLIENT) up to the max retry value.  In essence
 
757
        we try to treat the CTA as if it were another RR value in the
 
758
        HostDB record.
 
759
     */ 
 
760
    enum {
 
761
      OS_ADDR_TRY_DEFAULT, ///< Initial state, use what config says.
 
762
      OS_ADDR_TRY_HOSTDB, ///< Try HostDB data.
 
763
      OS_ADDR_TRY_CLIENT, ///< Try client target addr.
 
764
      OS_ADDR_USE_HOSTDB, ///< Force use of HostDB target address.
 
765
      OS_ADDR_USE_CLIENT ///< Use client target addr, no fallback.
 
766
    } os_addr_style;
 
767
 
837
768
    bool lookup_success;
838
769
    char *lookup_name;
839
770
    char srv_hostname[MAXDNAME];
840
771
    LookingUp_t looking_up;
841
772
    bool round_robin;
 
773
    bool srv_lookup_success;
 
774
    short srv_port;
 
775
    HostDBApplicationInfo srv_app;
842
776
 
843
777
    _DNSLookupInfo()
844
 
      : attempts(0),
845
 
        lookup_success(false), lookup_name(NULL), looking_up(UNDEFINED_LOOKUP), round_robin(false)
 
778
    : attempts(0), os_addr_style(OS_ADDR_TRY_DEFAULT),
 
779
        lookup_success(false), lookup_name(NULL), looking_up(UNDEFINED_LOOKUP), round_robin(false),
 
780
        srv_lookup_success(false), srv_port(0)
846
781
    {
847
 
      memset(&srv_hostname, 0, sizeof(srv_hostname));
 
782
      srv_hostname[0] = '\0';
 
783
      srv_app.allotment.application1 = 0;
 
784
      srv_app.allotment.application2 = 0;
848
785
    }
849
786
  } DNSLookupInfo;
850
787
 
888
825
    SquidLogCode log_code;
889
826
    SquidHierarchyCode hier_code;
890
827
    SquidHitMissCode hit_miss_code;
891
 
    WUTSProxyStatusCode wuts_proxy_status_code;
892
828
 
893
829
    _SquidLogInfo()
894
 
      : log_code(SQUID_LOG_ERR_UNKNOWN),
895
 
      hier_code(SQUID_HIER_EMPTY), hit_miss_code(SQUID_MISS_NONE), wuts_proxy_status_code(WUTS_PROXY_STATUS_UNKNOWN)
 
830
      : log_code(SQUID_LOG_ERR_UNKNOWN), hier_code(SQUID_HIER_EMPTY),
 
831
        hit_miss_code(SQUID_MISS_NONE)
896
832
    { }
897
833
  } SquidLogInfo;
898
834
 
983
919
 
984
920
    // for negative caching
985
921
    bool negative_caching;
986
 
 
 
922
    // for srv_lookup
 
923
    bool srv_lookup;
987
924
    // for authenticated content caching
988
925
    CacheAuth_t www_auth_content;
989
926
 
1051
988
    
1052
989
    // Http Range: related variables
1053
990
    RangeSetup_t range_setup;
1054
 
    bool unsatisfiable_range;
1055
 
    bool not_handle_range;
1056
991
    int64_t num_range_fields;
1057
992
    int64_t range_output_cl;
1058
 
    int64_t current_range;
1059
993
    RangeRecord *ranges;
1060
994
    
1061
995
    OverridableHttpConfigParams *txn_conf;
1062
996
    OverridableHttpConfigParams my_txn_conf; // Storage for plugins, to avoid malloc
 
997
 
 
998
    bool transparent_passthrough;
1063
999
    
1064
1000
    // Methods
1065
1001
    void
1109
1045
        first_stats(),
1110
1046
        current_stats(NULL),
1111
1047
        negative_caching(false),
 
1048
        srv_lookup(false),
1112
1049
        www_auth_content(CACHE_AUTH_NONE),
1113
1050
        client_connection_enabled(true),
1114
1051
        acl_filtering_performed(false),
1149
1086
        pristine_url(),
1150
1087
        api_skip_all_remapping(false),
1151
1088
        range_setup(RANGE_NONE),
1152
 
        unsatisfiable_range(false),
1153
 
        not_handle_range(false),
1154
1089
        num_range_fields(0),
1155
1090
        range_output_cl(0),
1156
 
        current_range(-1),
1157
1091
        ranges(NULL),
1158
 
        txn_conf(NULL)
 
1092
        txn_conf(NULL),
 
1093
        transparent_passthrough(false)
1159
1094
    {
1160
1095
      int i;
1161
1096
      char *via_ptr = via_string;
1244
1179
      arena.reset();
1245
1180
      pristine_url.clear();
1246
1181
 
1247
 
      delete[] ranges; ranges = NULL;
 
1182
      delete[] ranges;
 
1183
      ranges = NULL;
1248
1184
      range_setup = RANGE_NONE;
1249
 
      unsatisfiable_range = true;
1250
1185
      return;
1251
1186
    }
1252
1187
 
1308
1243
  static void handle_response_from_parent(State* s);
1309
1244
  static void handle_response_from_server(State* s);
1310
1245
  static void delete_server_rr_entry(State* s, int max_retries);
1311
 
  static void delete_srv_entry(State* s, int max_retries);
1312
1246
  static void retry_server_connection_not_open(State* s, ServerState_t conn_state, int max_retries);
1313
1247
  static void handle_server_connection_not_open(State* s);
1314
1248
  static void handle_forward_server_connection_open(State* s);