3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from google
.net
.proto
import ProtocolBuffer
22 import dummy_thread
as thread
24 __pychecker__
= """maxreturns=0 maxbranches=0 no-callinit
25 unusednames=printElemNumber,debug_strs no-special"""
27 if hasattr(ProtocolBuffer
, 'ExtendableProtocolMessage'):
28 _extension_runtime
= True
29 _ExtendableProtocolMessage
= ProtocolBuffer
.ExtendableProtocolMessage
31 _extension_runtime
= False
32 _ExtendableProtocolMessage
= ProtocolBuffer
.ProtocolMessage
34 class URLFetchServiceError(ProtocolBuffer
.ProtocolMessage
):
41 RESPONSE_TOO_LARGE
= 4
43 SSL_CERTIFICATE_ERROR
= 6
46 INTERNAL_TRANSIENT_ERROR
= 9
47 TOO_MANY_REDIRECTS
= 10
55 3: "UNSPECIFIED_ERROR",
56 4: "RESPONSE_TOO_LARGE",
57 5: "DEADLINE_EXCEEDED",
58 6: "SSL_CERTIFICATE_ERROR",
61 9: "INTERNAL_TRANSIENT_ERROR",
62 10: "TOO_MANY_REDIRECTS",
63 11: "MALFORMED_REPLY",
64 12: "CONNECTION_ERROR",
67 def ErrorCode_Name(cls
, x
): return cls
._ErrorCode
_NAMES
.get(x
, "")
68 ErrorCode_Name
= classmethod(ErrorCode_Name
)
71 def __init__(self
, contents
=None):
73 if contents
is not None: self
.MergeFromString(contents
)
76 def MergeFrom(self
, x
):
80 if x
is self
: return 1
83 def IsInitialized(self
, debug_strs
=None):
91 def ByteSizePartial(self
):
98 def OutputUnchecked(self
, out
):
101 def OutputPartial(self
, out
):
104 def TryMerge(self
, d
):
109 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
113 def __str__(self
, prefix
="", printElemNumber
=0):
118 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
119 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
122 _TEXT
= _BuildTagLookupTable({
126 _TYPES
= _BuildTagLookupTable({
127 0: ProtocolBuffer
.Encoder
.NUMERIC
,
128 }, 0, ProtocolBuffer
.Encoder
.MAX_TYPE
)
132 _STYLE_CONTENT_TYPE
= """"""
133 _PROTO_DESCRIPTOR_NAME
= 'apphosting.URLFetchServiceError'
134 class URLFetchRequest_Header(ProtocolBuffer
.ProtocolMessage
):
140 def __init__(self
, contents
=None):
141 if contents
is not None: self
.MergeFromString(contents
)
143 def key(self
): return self
.key_
145 def set_key(self
, x
):
154 def has_key(self
): return self
.has_key_
156 def value(self
): return self
.value_
158 def set_value(self
, x
):
162 def clear_value(self
):
167 def has_value(self
): return self
.has_value_
170 def MergeFrom(self
, x
):
172 if (x
.has_key()): self
.set_key(x
.key())
173 if (x
.has_value()): self
.set_value(x
.value())
176 if x
is self
: return 1
177 if self
.has_key_
!= x
.has_key_
: return 0
178 if self
.has_key_
and self
.key_
!= x
.key_
: return 0
179 if self
.has_value_
!= x
.has_value_
: return 0
180 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
183 def IsInitialized(self
, debug_strs
=None):
185 if (not self
.has_key_
):
187 if debug_strs
is not None:
188 debug_strs
.append('Required field: key not set.')
189 if (not self
.has_value_
):
191 if debug_strs
is not None:
192 debug_strs
.append('Required field: value not set.')
197 n
+= self
.lengthString(len(self
.key_
))
198 n
+= self
.lengthString(len(self
.value_
))
201 def ByteSizePartial(self
):
205 n
+= self
.lengthString(len(self
.key_
))
206 if (self
.has_value_
):
208 n
+= self
.lengthString(len(self
.value_
))
215 def OutputUnchecked(self
, out
):
217 out
.putPrefixedString(self
.key_
)
219 out
.putPrefixedString(self
.value_
)
221 def OutputPartial(self
, out
):
224 out
.putPrefixedString(self
.key_
)
225 if (self
.has_value_
):
227 out
.putPrefixedString(self
.value_
)
229 def TryMerge(self
, d
):
234 self
.set_key(d
.getPrefixedString())
237 self
.set_value(d
.getPrefixedString())
241 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
245 def __str__(self
, prefix
="", printElemNumber
=0):
247 if self
.has_key_
: res
+=prefix
+("Key: %s\n" % self
.DebugFormatString(self
.key_
))
248 if self
.has_value_
: res
+=prefix
+("Value: %s\n" % self
.DebugFormatString(self
.value_
))
251 class URLFetchRequest(ProtocolBuffer
.ProtocolMessage
):
261 _RequestMethod_NAMES
= {
270 def RequestMethod_Name(cls
, x
): return cls
._RequestMethod
_NAMES
.get(x
, "")
271 RequestMethod_Name
= classmethod(RequestMethod_Name
)
279 has_followredirects_
= 0
283 has_mustvalidateservercertificate_
= 0
284 mustvalidateservercertificate_
= 1
286 def __init__(self
, contents
=None):
288 if contents
is not None: self
.MergeFromString(contents
)
290 def method(self
): return self
.method_
292 def set_method(self
, x
):
296 def clear_method(self
):
301 def has_method(self
): return self
.has_method_
303 def url(self
): return self
.url_
305 def set_url(self
, x
):
314 def has_url(self
): return self
.has_url_
316 def header_size(self
): return len(self
.header_
)
317 def header_list(self
): return self
.header_
320 return self
.header_
[i
]
322 def mutable_header(self
, i
):
323 return self
.header_
[i
]
325 def add_header(self
):
326 x
= URLFetchRequest_Header()
327 self
.header_
.append(x
)
330 def clear_header(self
):
332 def payload(self
): return self
.payload_
334 def set_payload(self
, x
):
335 self
.has_payload_
= 1
338 def clear_payload(self
):
339 if self
.has_payload_
:
340 self
.has_payload_
= 0
343 def has_payload(self
): return self
.has_payload_
345 def followredirects(self
): return self
.followredirects_
347 def set_followredirects(self
, x
):
348 self
.has_followredirects_
= 1
349 self
.followredirects_
= x
351 def clear_followredirects(self
):
352 if self
.has_followredirects_
:
353 self
.has_followredirects_
= 0
354 self
.followredirects_
= 1
356 def has_followredirects(self
): return self
.has_followredirects_
358 def deadline(self
): return self
.deadline_
360 def set_deadline(self
, x
):
361 self
.has_deadline_
= 1
364 def clear_deadline(self
):
365 if self
.has_deadline_
:
366 self
.has_deadline_
= 0
369 def has_deadline(self
): return self
.has_deadline_
371 def mustvalidateservercertificate(self
): return self
.mustvalidateservercertificate_
373 def set_mustvalidateservercertificate(self
, x
):
374 self
.has_mustvalidateservercertificate_
= 1
375 self
.mustvalidateservercertificate_
= x
377 def clear_mustvalidateservercertificate(self
):
378 if self
.has_mustvalidateservercertificate_
:
379 self
.has_mustvalidateservercertificate_
= 0
380 self
.mustvalidateservercertificate_
= 1
382 def has_mustvalidateservercertificate(self
): return self
.has_mustvalidateservercertificate_
385 def MergeFrom(self
, x
):
387 if (x
.has_method()): self
.set_method(x
.method())
388 if (x
.has_url()): self
.set_url(x
.url())
389 for i
in xrange(x
.header_size()): self
.add_header().CopyFrom(x
.header(i
))
390 if (x
.has_payload()): self
.set_payload(x
.payload())
391 if (x
.has_followredirects()): self
.set_followredirects(x
.followredirects())
392 if (x
.has_deadline()): self
.set_deadline(x
.deadline())
393 if (x
.has_mustvalidateservercertificate()): self
.set_mustvalidateservercertificate(x
.mustvalidateservercertificate())
396 if x
is self
: return 1
397 if self
.has_method_
!= x
.has_method_
: return 0
398 if self
.has_method_
and self
.method_
!= x
.method_
: return 0
399 if self
.has_url_
!= x
.has_url_
: return 0
400 if self
.has_url_
and self
.url_
!= x
.url_
: return 0
401 if len(self
.header_
) != len(x
.header_
): return 0
402 for e1
, e2
in zip(self
.header_
, x
.header_
):
403 if e1
!= e2
: return 0
404 if self
.has_payload_
!= x
.has_payload_
: return 0
405 if self
.has_payload_
and self
.payload_
!= x
.payload_
: return 0
406 if self
.has_followredirects_
!= x
.has_followredirects_
: return 0
407 if self
.has_followredirects_
and self
.followredirects_
!= x
.followredirects_
: return 0
408 if self
.has_deadline_
!= x
.has_deadline_
: return 0
409 if self
.has_deadline_
and self
.deadline_
!= x
.deadline_
: return 0
410 if self
.has_mustvalidateservercertificate_
!= x
.has_mustvalidateservercertificate_
: return 0
411 if self
.has_mustvalidateservercertificate_
and self
.mustvalidateservercertificate_
!= x
.mustvalidateservercertificate_
: return 0
414 def IsInitialized(self
, debug_strs
=None):
416 if (not self
.has_method_
):
418 if debug_strs
is not None:
419 debug_strs
.append('Required field: method not set.')
420 if (not self
.has_url_
):
422 if debug_strs
is not None:
423 debug_strs
.append('Required field: url not set.')
424 for p
in self
.header_
:
425 if not p
.IsInitialized(debug_strs
): initialized
=0
430 n
+= self
.lengthVarInt64(self
.method_
)
431 n
+= self
.lengthString(len(self
.url_
))
432 n
+= 2 * len(self
.header_
)
433 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSize()
434 if (self
.has_payload_
): n
+= 1 + self
.lengthString(len(self
.payload_
))
435 if (self
.has_followredirects_
): n
+= 2
436 if (self
.has_deadline_
): n
+= 9
437 if (self
.has_mustvalidateservercertificate_
): n
+= 2
440 def ByteSizePartial(self
):
442 if (self
.has_method_
):
444 n
+= self
.lengthVarInt64(self
.method_
)
447 n
+= self
.lengthString(len(self
.url_
))
448 n
+= 2 * len(self
.header_
)
449 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSizePartial()
450 if (self
.has_payload_
): n
+= 1 + self
.lengthString(len(self
.payload_
))
451 if (self
.has_followredirects_
): n
+= 2
452 if (self
.has_deadline_
): n
+= 9
453 if (self
.has_mustvalidateservercertificate_
): n
+= 2
461 self
.clear_followredirects()
462 self
.clear_deadline()
463 self
.clear_mustvalidateservercertificate()
465 def OutputUnchecked(self
, out
):
467 out
.putVarInt32(self
.method_
)
469 out
.putPrefixedString(self
.url_
)
470 for i
in xrange(len(self
.header_
)):
472 self
.header_
[i
].OutputUnchecked(out
)
474 if (self
.has_payload_
):
476 out
.putPrefixedString(self
.payload_
)
477 if (self
.has_followredirects_
):
479 out
.putBoolean(self
.followredirects_
)
480 if (self
.has_deadline_
):
482 out
.putDouble(self
.deadline_
)
483 if (self
.has_mustvalidateservercertificate_
):
485 out
.putBoolean(self
.mustvalidateservercertificate_
)
487 def OutputPartial(self
, out
):
488 if (self
.has_method_
):
490 out
.putVarInt32(self
.method_
)
493 out
.putPrefixedString(self
.url_
)
494 for i
in xrange(len(self
.header_
)):
496 self
.header_
[i
].OutputPartial(out
)
498 if (self
.has_payload_
):
500 out
.putPrefixedString(self
.payload_
)
501 if (self
.has_followredirects_
):
503 out
.putBoolean(self
.followredirects_
)
504 if (self
.has_deadline_
):
506 out
.putDouble(self
.deadline_
)
507 if (self
.has_mustvalidateservercertificate_
):
509 out
.putBoolean(self
.mustvalidateservercertificate_
)
511 def TryMerge(self
, d
):
515 self
.set_method(d
.getVarInt32())
518 self
.set_url(d
.getPrefixedString())
521 self
.add_header().TryMerge(d
)
524 self
.set_payload(d
.getPrefixedString())
527 self
.set_followredirects(d
.getBoolean())
530 self
.set_deadline(d
.getDouble())
533 self
.set_mustvalidateservercertificate(d
.getBoolean())
537 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
541 def __str__(self
, prefix
="", printElemNumber
=0):
543 if self
.has_method_
: res
+=prefix
+("Method: %s\n" % self
.DebugFormatInt32(self
.method_
))
544 if self
.has_url_
: res
+=prefix
+("Url: %s\n" % self
.DebugFormatString(self
.url_
))
546 for e
in self
.header_
:
548 if printElemNumber
: elm
="(%d)" % cnt
549 res
+=prefix
+("Header%s {\n" % elm
)
550 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
553 if self
.has_payload_
: res
+=prefix
+("Payload: %s\n" % self
.DebugFormatString(self
.payload_
))
554 if self
.has_followredirects_
: res
+=prefix
+("FollowRedirects: %s\n" % self
.DebugFormatBool(self
.followredirects_
))
555 if self
.has_deadline_
: res
+=prefix
+("Deadline: %s\n" % self
.DebugFormat(self
.deadline_
))
556 if self
.has_mustvalidateservercertificate_
: res
+=prefix
+("MustValidateServerCertificate: %s\n" % self
.DebugFormatBool(self
.mustvalidateservercertificate_
))
560 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
561 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
571 kMustValidateServerCertificate
= 9
573 _TEXT
= _BuildTagLookupTable({
581 7: "FollowRedirects",
583 9: "MustValidateServerCertificate",
586 _TYPES
= _BuildTagLookupTable({
587 0: ProtocolBuffer
.Encoder
.NUMERIC
,
588 1: ProtocolBuffer
.Encoder
.NUMERIC
,
589 2: ProtocolBuffer
.Encoder
.STRING
,
590 3: ProtocolBuffer
.Encoder
.STARTGROUP
,
591 4: ProtocolBuffer
.Encoder
.STRING
,
592 5: ProtocolBuffer
.Encoder
.STRING
,
593 6: ProtocolBuffer
.Encoder
.STRING
,
594 7: ProtocolBuffer
.Encoder
.NUMERIC
,
595 8: ProtocolBuffer
.Encoder
.DOUBLE
,
596 9: ProtocolBuffer
.Encoder
.NUMERIC
,
597 }, 9, ProtocolBuffer
.Encoder
.MAX_TYPE
)
601 _STYLE_CONTENT_TYPE
= """"""
602 _PROTO_DESCRIPTOR_NAME
= 'apphosting.URLFetchRequest'
603 class URLFetchResponse_Header(ProtocolBuffer
.ProtocolMessage
):
609 def __init__(self
, contents
=None):
610 if contents
is not None: self
.MergeFromString(contents
)
612 def key(self
): return self
.key_
614 def set_key(self
, x
):
623 def has_key(self
): return self
.has_key_
625 def value(self
): return self
.value_
627 def set_value(self
, x
):
631 def clear_value(self
):
636 def has_value(self
): return self
.has_value_
639 def MergeFrom(self
, x
):
641 if (x
.has_key()): self
.set_key(x
.key())
642 if (x
.has_value()): self
.set_value(x
.value())
645 if x
is self
: return 1
646 if self
.has_key_
!= x
.has_key_
: return 0
647 if self
.has_key_
and self
.key_
!= x
.key_
: return 0
648 if self
.has_value_
!= x
.has_value_
: return 0
649 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
652 def IsInitialized(self
, debug_strs
=None):
654 if (not self
.has_key_
):
656 if debug_strs
is not None:
657 debug_strs
.append('Required field: key not set.')
658 if (not self
.has_value_
):
660 if debug_strs
is not None:
661 debug_strs
.append('Required field: value not set.')
666 n
+= self
.lengthString(len(self
.key_
))
667 n
+= self
.lengthString(len(self
.value_
))
670 def ByteSizePartial(self
):
674 n
+= self
.lengthString(len(self
.key_
))
675 if (self
.has_value_
):
677 n
+= self
.lengthString(len(self
.value_
))
684 def OutputUnchecked(self
, out
):
686 out
.putPrefixedString(self
.key_
)
688 out
.putPrefixedString(self
.value_
)
690 def OutputPartial(self
, out
):
693 out
.putPrefixedString(self
.key_
)
694 if (self
.has_value_
):
696 out
.putPrefixedString(self
.value_
)
698 def TryMerge(self
, d
):
703 self
.set_key(d
.getPrefixedString())
706 self
.set_value(d
.getPrefixedString())
710 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
714 def __str__(self
, prefix
="", printElemNumber
=0):
716 if self
.has_key_
: res
+=prefix
+("Key: %s\n" % self
.DebugFormatString(self
.key_
))
717 if self
.has_value_
: res
+=prefix
+("Value: %s\n" % self
.DebugFormatString(self
.value_
))
720 class URLFetchResponse(ProtocolBuffer
.ProtocolMessage
):
725 has_contentwastruncated_
= 0
726 contentwastruncated_
= 0
727 has_externalbytessent_
= 0
728 externalbytessent_
= 0
729 has_externalbytesreceived_
= 0
730 externalbytesreceived_
= 0
733 has_apicpumilliseconds_
= 0
734 apicpumilliseconds_
= 0
735 has_apibytessent_
= 0
737 has_apibytesreceived_
= 0
738 apibytesreceived_
= 0
740 def __init__(self
, contents
=None):
742 if contents
is not None: self
.MergeFromString(contents
)
744 def content(self
): return self
.content_
746 def set_content(self
, x
):
747 self
.has_content_
= 1
750 def clear_content(self
):
751 if self
.has_content_
:
752 self
.has_content_
= 0
755 def has_content(self
): return self
.has_content_
757 def statuscode(self
): return self
.statuscode_
759 def set_statuscode(self
, x
):
760 self
.has_statuscode_
= 1
763 def clear_statuscode(self
):
764 if self
.has_statuscode_
:
765 self
.has_statuscode_
= 0
768 def has_statuscode(self
): return self
.has_statuscode_
770 def header_size(self
): return len(self
.header_
)
771 def header_list(self
): return self
.header_
774 return self
.header_
[i
]
776 def mutable_header(self
, i
):
777 return self
.header_
[i
]
779 def add_header(self
):
780 x
= URLFetchResponse_Header()
781 self
.header_
.append(x
)
784 def clear_header(self
):
786 def contentwastruncated(self
): return self
.contentwastruncated_
788 def set_contentwastruncated(self
, x
):
789 self
.has_contentwastruncated_
= 1
790 self
.contentwastruncated_
= x
792 def clear_contentwastruncated(self
):
793 if self
.has_contentwastruncated_
:
794 self
.has_contentwastruncated_
= 0
795 self
.contentwastruncated_
= 0
797 def has_contentwastruncated(self
): return self
.has_contentwastruncated_
799 def externalbytessent(self
): return self
.externalbytessent_
801 def set_externalbytessent(self
, x
):
802 self
.has_externalbytessent_
= 1
803 self
.externalbytessent_
= x
805 def clear_externalbytessent(self
):
806 if self
.has_externalbytessent_
:
807 self
.has_externalbytessent_
= 0
808 self
.externalbytessent_
= 0
810 def has_externalbytessent(self
): return self
.has_externalbytessent_
812 def externalbytesreceived(self
): return self
.externalbytesreceived_
814 def set_externalbytesreceived(self
, x
):
815 self
.has_externalbytesreceived_
= 1
816 self
.externalbytesreceived_
= x
818 def clear_externalbytesreceived(self
):
819 if self
.has_externalbytesreceived_
:
820 self
.has_externalbytesreceived_
= 0
821 self
.externalbytesreceived_
= 0
823 def has_externalbytesreceived(self
): return self
.has_externalbytesreceived_
825 def finalurl(self
): return self
.finalurl_
827 def set_finalurl(self
, x
):
828 self
.has_finalurl_
= 1
831 def clear_finalurl(self
):
832 if self
.has_finalurl_
:
833 self
.has_finalurl_
= 0
836 def has_finalurl(self
): return self
.has_finalurl_
838 def apicpumilliseconds(self
): return self
.apicpumilliseconds_
840 def set_apicpumilliseconds(self
, x
):
841 self
.has_apicpumilliseconds_
= 1
842 self
.apicpumilliseconds_
= x
844 def clear_apicpumilliseconds(self
):
845 if self
.has_apicpumilliseconds_
:
846 self
.has_apicpumilliseconds_
= 0
847 self
.apicpumilliseconds_
= 0
849 def has_apicpumilliseconds(self
): return self
.has_apicpumilliseconds_
851 def apibytessent(self
): return self
.apibytessent_
853 def set_apibytessent(self
, x
):
854 self
.has_apibytessent_
= 1
855 self
.apibytessent_
= x
857 def clear_apibytessent(self
):
858 if self
.has_apibytessent_
:
859 self
.has_apibytessent_
= 0
860 self
.apibytessent_
= 0
862 def has_apibytessent(self
): return self
.has_apibytessent_
864 def apibytesreceived(self
): return self
.apibytesreceived_
866 def set_apibytesreceived(self
, x
):
867 self
.has_apibytesreceived_
= 1
868 self
.apibytesreceived_
= x
870 def clear_apibytesreceived(self
):
871 if self
.has_apibytesreceived_
:
872 self
.has_apibytesreceived_
= 0
873 self
.apibytesreceived_
= 0
875 def has_apibytesreceived(self
): return self
.has_apibytesreceived_
878 def MergeFrom(self
, x
):
880 if (x
.has_content()): self
.set_content(x
.content())
881 if (x
.has_statuscode()): self
.set_statuscode(x
.statuscode())
882 for i
in xrange(x
.header_size()): self
.add_header().CopyFrom(x
.header(i
))
883 if (x
.has_contentwastruncated()): self
.set_contentwastruncated(x
.contentwastruncated())
884 if (x
.has_externalbytessent()): self
.set_externalbytessent(x
.externalbytessent())
885 if (x
.has_externalbytesreceived()): self
.set_externalbytesreceived(x
.externalbytesreceived())
886 if (x
.has_finalurl()): self
.set_finalurl(x
.finalurl())
887 if (x
.has_apicpumilliseconds()): self
.set_apicpumilliseconds(x
.apicpumilliseconds())
888 if (x
.has_apibytessent()): self
.set_apibytessent(x
.apibytessent())
889 if (x
.has_apibytesreceived()): self
.set_apibytesreceived(x
.apibytesreceived())
892 if x
is self
: return 1
893 if self
.has_content_
!= x
.has_content_
: return 0
894 if self
.has_content_
and self
.content_
!= x
.content_
: return 0
895 if self
.has_statuscode_
!= x
.has_statuscode_
: return 0
896 if self
.has_statuscode_
and self
.statuscode_
!= x
.statuscode_
: return 0
897 if len(self
.header_
) != len(x
.header_
): return 0
898 for e1
, e2
in zip(self
.header_
, x
.header_
):
899 if e1
!= e2
: return 0
900 if self
.has_contentwastruncated_
!= x
.has_contentwastruncated_
: return 0
901 if self
.has_contentwastruncated_
and self
.contentwastruncated_
!= x
.contentwastruncated_
: return 0
902 if self
.has_externalbytessent_
!= x
.has_externalbytessent_
: return 0
903 if self
.has_externalbytessent_
and self
.externalbytessent_
!= x
.externalbytessent_
: return 0
904 if self
.has_externalbytesreceived_
!= x
.has_externalbytesreceived_
: return 0
905 if self
.has_externalbytesreceived_
and self
.externalbytesreceived_
!= x
.externalbytesreceived_
: return 0
906 if self
.has_finalurl_
!= x
.has_finalurl_
: return 0
907 if self
.has_finalurl_
and self
.finalurl_
!= x
.finalurl_
: return 0
908 if self
.has_apicpumilliseconds_
!= x
.has_apicpumilliseconds_
: return 0
909 if self
.has_apicpumilliseconds_
and self
.apicpumilliseconds_
!= x
.apicpumilliseconds_
: return 0
910 if self
.has_apibytessent_
!= x
.has_apibytessent_
: return 0
911 if self
.has_apibytessent_
and self
.apibytessent_
!= x
.apibytessent_
: return 0
912 if self
.has_apibytesreceived_
!= x
.has_apibytesreceived_
: return 0
913 if self
.has_apibytesreceived_
and self
.apibytesreceived_
!= x
.apibytesreceived_
: return 0
916 def IsInitialized(self
, debug_strs
=None):
918 if (not self
.has_statuscode_
):
920 if debug_strs
is not None:
921 debug_strs
.append('Required field: statuscode not set.')
922 for p
in self
.header_
:
923 if not p
.IsInitialized(debug_strs
): initialized
=0
928 if (self
.has_content_
): n
+= 1 + self
.lengthString(len(self
.content_
))
929 n
+= self
.lengthVarInt64(self
.statuscode_
)
930 n
+= 2 * len(self
.header_
)
931 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSize()
932 if (self
.has_contentwastruncated_
): n
+= 2
933 if (self
.has_externalbytessent_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytessent_
)
934 if (self
.has_externalbytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytesreceived_
)
935 if (self
.has_finalurl_
): n
+= 1 + self
.lengthString(len(self
.finalurl_
))
936 if (self
.has_apicpumilliseconds_
): n
+= 1 + self
.lengthVarInt64(self
.apicpumilliseconds_
)
937 if (self
.has_apibytessent_
): n
+= 1 + self
.lengthVarInt64(self
.apibytessent_
)
938 if (self
.has_apibytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.apibytesreceived_
)
941 def ByteSizePartial(self
):
943 if (self
.has_content_
): n
+= 1 + self
.lengthString(len(self
.content_
))
944 if (self
.has_statuscode_
):
946 n
+= self
.lengthVarInt64(self
.statuscode_
)
947 n
+= 2 * len(self
.header_
)
948 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSizePartial()
949 if (self
.has_contentwastruncated_
): n
+= 2
950 if (self
.has_externalbytessent_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytessent_
)
951 if (self
.has_externalbytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytesreceived_
)
952 if (self
.has_finalurl_
): n
+= 1 + self
.lengthString(len(self
.finalurl_
))
953 if (self
.has_apicpumilliseconds_
): n
+= 1 + self
.lengthVarInt64(self
.apicpumilliseconds_
)
954 if (self
.has_apibytessent_
): n
+= 1 + self
.lengthVarInt64(self
.apibytessent_
)
955 if (self
.has_apibytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.apibytesreceived_
)
960 self
.clear_statuscode()
962 self
.clear_contentwastruncated()
963 self
.clear_externalbytessent()
964 self
.clear_externalbytesreceived()
965 self
.clear_finalurl()
966 self
.clear_apicpumilliseconds()
967 self
.clear_apibytessent()
968 self
.clear_apibytesreceived()
970 def OutputUnchecked(self
, out
):
971 if (self
.has_content_
):
973 out
.putPrefixedString(self
.content_
)
975 out
.putVarInt32(self
.statuscode_
)
976 for i
in xrange(len(self
.header_
)):
978 self
.header_
[i
].OutputUnchecked(out
)
980 if (self
.has_contentwastruncated_
):
982 out
.putBoolean(self
.contentwastruncated_
)
983 if (self
.has_externalbytessent_
):
985 out
.putVarInt64(self
.externalbytessent_
)
986 if (self
.has_externalbytesreceived_
):
988 out
.putVarInt64(self
.externalbytesreceived_
)
989 if (self
.has_finalurl_
):
991 out
.putPrefixedString(self
.finalurl_
)
992 if (self
.has_apicpumilliseconds_
):
994 out
.putVarInt64(self
.apicpumilliseconds_
)
995 if (self
.has_apibytessent_
):
997 out
.putVarInt64(self
.apibytessent_
)
998 if (self
.has_apibytesreceived_
):
1000 out
.putVarInt64(self
.apibytesreceived_
)
1002 def OutputPartial(self
, out
):
1003 if (self
.has_content_
):
1005 out
.putPrefixedString(self
.content_
)
1006 if (self
.has_statuscode_
):
1008 out
.putVarInt32(self
.statuscode_
)
1009 for i
in xrange(len(self
.header_
)):
1011 self
.header_
[i
].OutputPartial(out
)
1013 if (self
.has_contentwastruncated_
):
1015 out
.putBoolean(self
.contentwastruncated_
)
1016 if (self
.has_externalbytessent_
):
1018 out
.putVarInt64(self
.externalbytessent_
)
1019 if (self
.has_externalbytesreceived_
):
1021 out
.putVarInt64(self
.externalbytesreceived_
)
1022 if (self
.has_finalurl_
):
1024 out
.putPrefixedString(self
.finalurl_
)
1025 if (self
.has_apicpumilliseconds_
):
1027 out
.putVarInt64(self
.apicpumilliseconds_
)
1028 if (self
.has_apibytessent_
):
1030 out
.putVarInt64(self
.apibytessent_
)
1031 if (self
.has_apibytesreceived_
):
1033 out
.putVarInt64(self
.apibytesreceived_
)
1035 def TryMerge(self
, d
):
1036 while d
.avail() > 0:
1037 tt
= d
.getVarInt32()
1039 self
.set_content(d
.getPrefixedString())
1042 self
.set_statuscode(d
.getVarInt32())
1045 self
.add_header().TryMerge(d
)
1048 self
.set_contentwastruncated(d
.getBoolean())
1051 self
.set_externalbytessent(d
.getVarInt64())
1054 self
.set_externalbytesreceived(d
.getVarInt64())
1057 self
.set_finalurl(d
.getPrefixedString())
1060 self
.set_apicpumilliseconds(d
.getVarInt64())
1063 self
.set_apibytessent(d
.getVarInt64())
1066 self
.set_apibytesreceived(d
.getVarInt64())
1070 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1074 def __str__(self
, prefix
="", printElemNumber
=0):
1076 if self
.has_content_
: res
+=prefix
+("Content: %s\n" % self
.DebugFormatString(self
.content_
))
1077 if self
.has_statuscode_
: res
+=prefix
+("StatusCode: %s\n" % self
.DebugFormatInt32(self
.statuscode_
))
1079 for e
in self
.header_
:
1081 if printElemNumber
: elm
="(%d)" % cnt
1082 res
+=prefix
+("Header%s {\n" % elm
)
1083 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1086 if self
.has_contentwastruncated_
: res
+=prefix
+("ContentWasTruncated: %s\n" % self
.DebugFormatBool(self
.contentwastruncated_
))
1087 if self
.has_externalbytessent_
: res
+=prefix
+("ExternalBytesSent: %s\n" % self
.DebugFormatInt64(self
.externalbytessent_
))
1088 if self
.has_externalbytesreceived_
: res
+=prefix
+("ExternalBytesReceived: %s\n" % self
.DebugFormatInt64(self
.externalbytesreceived_
))
1089 if self
.has_finalurl_
: res
+=prefix
+("FinalUrl: %s\n" % self
.DebugFormatString(self
.finalurl_
))
1090 if self
.has_apicpumilliseconds_
: res
+=prefix
+("ApiCpuMilliseconds: %s\n" % self
.DebugFormatInt64(self
.apicpumilliseconds_
))
1091 if self
.has_apibytessent_
: res
+=prefix
+("ApiBytesSent: %s\n" % self
.DebugFormatInt64(self
.apibytessent_
))
1092 if self
.has_apibytesreceived_
: res
+=prefix
+("ApiBytesReceived: %s\n" % self
.DebugFormatInt64(self
.apibytesreceived_
))
1096 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1097 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1104 kContentWasTruncated
= 6
1105 kExternalBytesSent
= 7
1106 kExternalBytesReceived
= 8
1108 kApiCpuMilliseconds
= 10
1110 kApiBytesReceived
= 12
1112 _TEXT
= _BuildTagLookupTable({
1119 6: "ContentWasTruncated",
1120 7: "ExternalBytesSent",
1121 8: "ExternalBytesReceived",
1123 10: "ApiCpuMilliseconds",
1125 12: "ApiBytesReceived",
1128 _TYPES
= _BuildTagLookupTable({
1129 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1130 1: ProtocolBuffer
.Encoder
.STRING
,
1131 2: ProtocolBuffer
.Encoder
.NUMERIC
,
1132 3: ProtocolBuffer
.Encoder
.STARTGROUP
,
1133 4: ProtocolBuffer
.Encoder
.STRING
,
1134 5: ProtocolBuffer
.Encoder
.STRING
,
1135 6: ProtocolBuffer
.Encoder
.NUMERIC
,
1136 7: ProtocolBuffer
.Encoder
.NUMERIC
,
1137 8: ProtocolBuffer
.Encoder
.NUMERIC
,
1138 9: ProtocolBuffer
.Encoder
.STRING
,
1139 10: ProtocolBuffer
.Encoder
.NUMERIC
,
1140 11: ProtocolBuffer
.Encoder
.NUMERIC
,
1141 12: ProtocolBuffer
.Encoder
.NUMERIC
,
1142 }, 12, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1146 _STYLE_CONTENT_TYPE
= """"""
1147 _PROTO_DESCRIPTOR_NAME
= 'apphosting.URLFetchResponse'
1148 if _extension_runtime
:
1151 __all__
= ['URLFetchServiceError','URLFetchRequest','URLFetchRequest_Header','URLFetchResponse','URLFetchResponse_Header']