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.
18 from google
.net
.proto
import ProtocolBuffer
20 import dummy_thread
as thread
22 __pychecker__
= """maxreturns=0 maxbranches=0 no-callinit
23 unusednames=printElemNumber,debug_strs no-special"""
25 class URLFetchServiceError(ProtocolBuffer
.ProtocolMessage
):
31 RESPONSE_TOO_LARGE
= 4
38 3: "UNSPECIFIED_ERROR",
39 4: "RESPONSE_TOO_LARGE",
40 5: "DEADLINE_EXCEEDED",
43 def ErrorCode_Name(cls
, x
): return cls
._ErrorCode
_NAMES
.get(x
, "")
44 ErrorCode_Name
= classmethod(ErrorCode_Name
)
47 def __init__(self
, contents
=None):
49 if contents
is not None: self
.MergeFromString(contents
)
52 def MergeFrom(self
, x
):
56 if x
is self
: return 1
59 def IsInitialized(self
, debug_strs
=None):
70 def OutputUnchecked(self
, out
):
73 def TryMerge(self
, d
):
76 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
80 def __str__(self
, prefix
="", printElemNumber
=0):
85 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
86 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
89 _TEXT
= _BuildTagLookupTable({
93 _TYPES
= _BuildTagLookupTable({
94 0: ProtocolBuffer
.Encoder
.NUMERIC
,
95 }, 0, ProtocolBuffer
.Encoder
.MAX_TYPE
)
98 _STYLE_CONTENT_TYPE
= """"""
99 class URLFetchRequest_Header(ProtocolBuffer
.ProtocolMessage
):
105 def __init__(self
, contents
=None):
106 if contents
is not None: self
.MergeFromString(contents
)
108 def key(self
): return self
.key_
110 def set_key(self
, x
):
119 def has_key(self
): return self
.has_key_
121 def value(self
): return self
.value_
123 def set_value(self
, x
):
127 def clear_value(self
):
132 def has_value(self
): return self
.has_value_
135 def MergeFrom(self
, x
):
137 if (x
.has_key()): self
.set_key(x
.key())
138 if (x
.has_value()): self
.set_value(x
.value())
141 if x
is self
: return 1
142 if self
.has_key_
!= x
.has_key_
: return 0
143 if self
.has_key_
and self
.key_
!= x
.key_
: return 0
144 if self
.has_value_
!= x
.has_value_
: return 0
145 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
148 def IsInitialized(self
, debug_strs
=None):
150 if (not self
.has_key_
):
152 if debug_strs
is not None:
153 debug_strs
.append('Required field: key not set.')
154 if (not self
.has_value_
):
156 if debug_strs
is not None:
157 debug_strs
.append('Required field: value not set.')
162 n
+= self
.lengthString(len(self
.key_
))
163 n
+= self
.lengthString(len(self
.value_
))
170 def OutputUnchecked(self
, out
):
172 out
.putPrefixedString(self
.key_
)
174 out
.putPrefixedString(self
.value_
)
176 def TryMerge(self
, d
):
181 self
.set_key(d
.getPrefixedString())
184 self
.set_value(d
.getPrefixedString())
186 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
190 def __str__(self
, prefix
="", printElemNumber
=0):
192 if self
.has_key_
: res
+=prefix
+("Key: %s\n" % self
.DebugFormatString(self
.key_
))
193 if self
.has_value_
: res
+=prefix
+("Value: %s\n" % self
.DebugFormatString(self
.value_
))
196 class URLFetchRequest(ProtocolBuffer
.ProtocolMessage
):
204 _RequestMethod_NAMES
= {
212 def RequestMethod_Name(cls
, x
): return cls
._RequestMethod
_NAMES
.get(x
, "")
213 RequestMethod_Name
= classmethod(RequestMethod_Name
)
221 has_followredirects_
= 0
226 def __init__(self
, contents
=None):
228 if contents
is not None: self
.MergeFromString(contents
)
230 def method(self
): return self
.method_
232 def set_method(self
, x
):
236 def clear_method(self
):
241 def has_method(self
): return self
.has_method_
243 def url(self
): return self
.url_
245 def set_url(self
, x
):
254 def has_url(self
): return self
.has_url_
256 def header_size(self
): return len(self
.header_
)
257 def header_list(self
): return self
.header_
260 return self
.header_
[i
]
262 def mutable_header(self
, i
):
263 return self
.header_
[i
]
265 def add_header(self
):
266 x
= URLFetchRequest_Header()
267 self
.header_
.append(x
)
270 def clear_header(self
):
272 def payload(self
): return self
.payload_
274 def set_payload(self
, x
):
275 self
.has_payload_
= 1
278 def clear_payload(self
):
279 if self
.has_payload_
:
280 self
.has_payload_
= 0
283 def has_payload(self
): return self
.has_payload_
285 def followredirects(self
): return self
.followredirects_
287 def set_followredirects(self
, x
):
288 self
.has_followredirects_
= 1
289 self
.followredirects_
= x
291 def clear_followredirects(self
):
292 if self
.has_followredirects_
:
293 self
.has_followredirects_
= 0
294 self
.followredirects_
= 1
296 def has_followredirects(self
): return self
.has_followredirects_
298 def deadline(self
): return self
.deadline_
300 def set_deadline(self
, x
):
301 self
.has_deadline_
= 1
304 def clear_deadline(self
):
305 if self
.has_deadline_
:
306 self
.has_deadline_
= 0
309 def has_deadline(self
): return self
.has_deadline_
312 def MergeFrom(self
, x
):
314 if (x
.has_method()): self
.set_method(x
.method())
315 if (x
.has_url()): self
.set_url(x
.url())
316 for i
in xrange(x
.header_size()): self
.add_header().CopyFrom(x
.header(i
))
317 if (x
.has_payload()): self
.set_payload(x
.payload())
318 if (x
.has_followredirects()): self
.set_followredirects(x
.followredirects())
319 if (x
.has_deadline()): self
.set_deadline(x
.deadline())
322 if x
is self
: return 1
323 if self
.has_method_
!= x
.has_method_
: return 0
324 if self
.has_method_
and self
.method_
!= x
.method_
: return 0
325 if self
.has_url_
!= x
.has_url_
: return 0
326 if self
.has_url_
and self
.url_
!= x
.url_
: return 0
327 if len(self
.header_
) != len(x
.header_
): return 0
328 for e1
, e2
in zip(self
.header_
, x
.header_
):
329 if e1
!= e2
: return 0
330 if self
.has_payload_
!= x
.has_payload_
: return 0
331 if self
.has_payload_
and self
.payload_
!= x
.payload_
: return 0
332 if self
.has_followredirects_
!= x
.has_followredirects_
: return 0
333 if self
.has_followredirects_
and self
.followredirects_
!= x
.followredirects_
: return 0
334 if self
.has_deadline_
!= x
.has_deadline_
: return 0
335 if self
.has_deadline_
and self
.deadline_
!= x
.deadline_
: return 0
338 def IsInitialized(self
, debug_strs
=None):
340 if (not self
.has_method_
):
342 if debug_strs
is not None:
343 debug_strs
.append('Required field: method not set.')
344 if (not self
.has_url_
):
346 if debug_strs
is not None:
347 debug_strs
.append('Required field: url not set.')
348 for p
in self
.header_
:
349 if not p
.IsInitialized(debug_strs
): initialized
=0
354 n
+= self
.lengthVarInt64(self
.method_
)
355 n
+= self
.lengthString(len(self
.url_
))
356 n
+= 2 * len(self
.header_
)
357 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSize()
358 if (self
.has_payload_
): n
+= 1 + self
.lengthString(len(self
.payload_
))
359 if (self
.has_followredirects_
): n
+= 2
360 if (self
.has_deadline_
): n
+= 9
368 self
.clear_followredirects()
369 self
.clear_deadline()
371 def OutputUnchecked(self
, out
):
373 out
.putVarInt32(self
.method_
)
375 out
.putPrefixedString(self
.url_
)
376 for i
in xrange(len(self
.header_
)):
378 self
.header_
[i
].OutputUnchecked(out
)
380 if (self
.has_payload_
):
382 out
.putPrefixedString(self
.payload_
)
383 if (self
.has_followredirects_
):
385 out
.putBoolean(self
.followredirects_
)
386 if (self
.has_deadline_
):
388 out
.putDouble(self
.deadline_
)
390 def TryMerge(self
, d
):
394 self
.set_method(d
.getVarInt32())
397 self
.set_url(d
.getPrefixedString())
400 self
.add_header().TryMerge(d
)
403 self
.set_payload(d
.getPrefixedString())
406 self
.set_followredirects(d
.getBoolean())
409 self
.set_deadline(d
.getDouble())
411 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
415 def __str__(self
, prefix
="", printElemNumber
=0):
417 if self
.has_method_
: res
+=prefix
+("Method: %s\n" % self
.DebugFormatInt32(self
.method_
))
418 if self
.has_url_
: res
+=prefix
+("Url: %s\n" % self
.DebugFormatString(self
.url_
))
420 for e
in self
.header_
:
422 if printElemNumber
: elm
="(%d)" % cnt
423 res
+=prefix
+("Header%s {\n" % elm
)
424 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
427 if self
.has_payload_
: res
+=prefix
+("Payload: %s\n" % self
.DebugFormatString(self
.payload_
))
428 if self
.has_followredirects_
: res
+=prefix
+("FollowRedirects: %s\n" % self
.DebugFormatBool(self
.followredirects_
))
429 if self
.has_deadline_
: res
+=prefix
+("Deadline: %s\n" % self
.DebugFormat(self
.deadline_
))
433 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
434 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
445 _TEXT
= _BuildTagLookupTable({
453 7: "FollowRedirects",
457 _TYPES
= _BuildTagLookupTable({
458 0: ProtocolBuffer
.Encoder
.NUMERIC
,
459 1: ProtocolBuffer
.Encoder
.NUMERIC
,
460 2: ProtocolBuffer
.Encoder
.STRING
,
461 3: ProtocolBuffer
.Encoder
.STARTGROUP
,
462 4: ProtocolBuffer
.Encoder
.STRING
,
463 5: ProtocolBuffer
.Encoder
.STRING
,
464 6: ProtocolBuffer
.Encoder
.STRING
,
465 7: ProtocolBuffer
.Encoder
.NUMERIC
,
466 8: ProtocolBuffer
.Encoder
.DOUBLE
,
467 }, 8, ProtocolBuffer
.Encoder
.MAX_TYPE
)
470 _STYLE_CONTENT_TYPE
= """"""
471 class URLFetchResponse_Header(ProtocolBuffer
.ProtocolMessage
):
477 def __init__(self
, contents
=None):
478 if contents
is not None: self
.MergeFromString(contents
)
480 def key(self
): return self
.key_
482 def set_key(self
, x
):
491 def has_key(self
): return self
.has_key_
493 def value(self
): return self
.value_
495 def set_value(self
, x
):
499 def clear_value(self
):
504 def has_value(self
): return self
.has_value_
507 def MergeFrom(self
, x
):
509 if (x
.has_key()): self
.set_key(x
.key())
510 if (x
.has_value()): self
.set_value(x
.value())
513 if x
is self
: return 1
514 if self
.has_key_
!= x
.has_key_
: return 0
515 if self
.has_key_
and self
.key_
!= x
.key_
: return 0
516 if self
.has_value_
!= x
.has_value_
: return 0
517 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
520 def IsInitialized(self
, debug_strs
=None):
522 if (not self
.has_key_
):
524 if debug_strs
is not None:
525 debug_strs
.append('Required field: key not set.')
526 if (not self
.has_value_
):
528 if debug_strs
is not None:
529 debug_strs
.append('Required field: value not set.')
534 n
+= self
.lengthString(len(self
.key_
))
535 n
+= self
.lengthString(len(self
.value_
))
542 def OutputUnchecked(self
, out
):
544 out
.putPrefixedString(self
.key_
)
546 out
.putPrefixedString(self
.value_
)
548 def TryMerge(self
, d
):
553 self
.set_key(d
.getPrefixedString())
556 self
.set_value(d
.getPrefixedString())
558 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
562 def __str__(self
, prefix
="", printElemNumber
=0):
564 if self
.has_key_
: res
+=prefix
+("Key: %s\n" % self
.DebugFormatString(self
.key_
))
565 if self
.has_value_
: res
+=prefix
+("Value: %s\n" % self
.DebugFormatString(self
.value_
))
568 class URLFetchResponse(ProtocolBuffer
.ProtocolMessage
):
573 has_contentwastruncated_
= 0
574 contentwastruncated_
= 0
575 has_externalbytessent_
= 0
576 externalbytessent_
= 0
577 has_externalbytesreceived_
= 0
578 externalbytesreceived_
= 0
581 has_apicpumilliseconds_
= 0
582 apicpumilliseconds_
= 0
583 has_apibytessent_
= 0
585 has_apibytesreceived_
= 0
586 apibytesreceived_
= 0
588 def __init__(self
, contents
=None):
590 if contents
is not None: self
.MergeFromString(contents
)
592 def content(self
): return self
.content_
594 def set_content(self
, x
):
595 self
.has_content_
= 1
598 def clear_content(self
):
599 if self
.has_content_
:
600 self
.has_content_
= 0
603 def has_content(self
): return self
.has_content_
605 def statuscode(self
): return self
.statuscode_
607 def set_statuscode(self
, x
):
608 self
.has_statuscode_
= 1
611 def clear_statuscode(self
):
612 if self
.has_statuscode_
:
613 self
.has_statuscode_
= 0
616 def has_statuscode(self
): return self
.has_statuscode_
618 def header_size(self
): return len(self
.header_
)
619 def header_list(self
): return self
.header_
622 return self
.header_
[i
]
624 def mutable_header(self
, i
):
625 return self
.header_
[i
]
627 def add_header(self
):
628 x
= URLFetchResponse_Header()
629 self
.header_
.append(x
)
632 def clear_header(self
):
634 def contentwastruncated(self
): return self
.contentwastruncated_
636 def set_contentwastruncated(self
, x
):
637 self
.has_contentwastruncated_
= 1
638 self
.contentwastruncated_
= x
640 def clear_contentwastruncated(self
):
641 if self
.has_contentwastruncated_
:
642 self
.has_contentwastruncated_
= 0
643 self
.contentwastruncated_
= 0
645 def has_contentwastruncated(self
): return self
.has_contentwastruncated_
647 def externalbytessent(self
): return self
.externalbytessent_
649 def set_externalbytessent(self
, x
):
650 self
.has_externalbytessent_
= 1
651 self
.externalbytessent_
= x
653 def clear_externalbytessent(self
):
654 if self
.has_externalbytessent_
:
655 self
.has_externalbytessent_
= 0
656 self
.externalbytessent_
= 0
658 def has_externalbytessent(self
): return self
.has_externalbytessent_
660 def externalbytesreceived(self
): return self
.externalbytesreceived_
662 def set_externalbytesreceived(self
, x
):
663 self
.has_externalbytesreceived_
= 1
664 self
.externalbytesreceived_
= x
666 def clear_externalbytesreceived(self
):
667 if self
.has_externalbytesreceived_
:
668 self
.has_externalbytesreceived_
= 0
669 self
.externalbytesreceived_
= 0
671 def has_externalbytesreceived(self
): return self
.has_externalbytesreceived_
673 def finalurl(self
): return self
.finalurl_
675 def set_finalurl(self
, x
):
676 self
.has_finalurl_
= 1
679 def clear_finalurl(self
):
680 if self
.has_finalurl_
:
681 self
.has_finalurl_
= 0
684 def has_finalurl(self
): return self
.has_finalurl_
686 def apicpumilliseconds(self
): return self
.apicpumilliseconds_
688 def set_apicpumilliseconds(self
, x
):
689 self
.has_apicpumilliseconds_
= 1
690 self
.apicpumilliseconds_
= x
692 def clear_apicpumilliseconds(self
):
693 if self
.has_apicpumilliseconds_
:
694 self
.has_apicpumilliseconds_
= 0
695 self
.apicpumilliseconds_
= 0
697 def has_apicpumilliseconds(self
): return self
.has_apicpumilliseconds_
699 def apibytessent(self
): return self
.apibytessent_
701 def set_apibytessent(self
, x
):
702 self
.has_apibytessent_
= 1
703 self
.apibytessent_
= x
705 def clear_apibytessent(self
):
706 if self
.has_apibytessent_
:
707 self
.has_apibytessent_
= 0
708 self
.apibytessent_
= 0
710 def has_apibytessent(self
): return self
.has_apibytessent_
712 def apibytesreceived(self
): return self
.apibytesreceived_
714 def set_apibytesreceived(self
, x
):
715 self
.has_apibytesreceived_
= 1
716 self
.apibytesreceived_
= x
718 def clear_apibytesreceived(self
):
719 if self
.has_apibytesreceived_
:
720 self
.has_apibytesreceived_
= 0
721 self
.apibytesreceived_
= 0
723 def has_apibytesreceived(self
): return self
.has_apibytesreceived_
726 def MergeFrom(self
, x
):
728 if (x
.has_content()): self
.set_content(x
.content())
729 if (x
.has_statuscode()): self
.set_statuscode(x
.statuscode())
730 for i
in xrange(x
.header_size()): self
.add_header().CopyFrom(x
.header(i
))
731 if (x
.has_contentwastruncated()): self
.set_contentwastruncated(x
.contentwastruncated())
732 if (x
.has_externalbytessent()): self
.set_externalbytessent(x
.externalbytessent())
733 if (x
.has_externalbytesreceived()): self
.set_externalbytesreceived(x
.externalbytesreceived())
734 if (x
.has_finalurl()): self
.set_finalurl(x
.finalurl())
735 if (x
.has_apicpumilliseconds()): self
.set_apicpumilliseconds(x
.apicpumilliseconds())
736 if (x
.has_apibytessent()): self
.set_apibytessent(x
.apibytessent())
737 if (x
.has_apibytesreceived()): self
.set_apibytesreceived(x
.apibytesreceived())
740 if x
is self
: return 1
741 if self
.has_content_
!= x
.has_content_
: return 0
742 if self
.has_content_
and self
.content_
!= x
.content_
: return 0
743 if self
.has_statuscode_
!= x
.has_statuscode_
: return 0
744 if self
.has_statuscode_
and self
.statuscode_
!= x
.statuscode_
: return 0
745 if len(self
.header_
) != len(x
.header_
): return 0
746 for e1
, e2
in zip(self
.header_
, x
.header_
):
747 if e1
!= e2
: return 0
748 if self
.has_contentwastruncated_
!= x
.has_contentwastruncated_
: return 0
749 if self
.has_contentwastruncated_
and self
.contentwastruncated_
!= x
.contentwastruncated_
: return 0
750 if self
.has_externalbytessent_
!= x
.has_externalbytessent_
: return 0
751 if self
.has_externalbytessent_
and self
.externalbytessent_
!= x
.externalbytessent_
: return 0
752 if self
.has_externalbytesreceived_
!= x
.has_externalbytesreceived_
: return 0
753 if self
.has_externalbytesreceived_
and self
.externalbytesreceived_
!= x
.externalbytesreceived_
: return 0
754 if self
.has_finalurl_
!= x
.has_finalurl_
: return 0
755 if self
.has_finalurl_
and self
.finalurl_
!= x
.finalurl_
: return 0
756 if self
.has_apicpumilliseconds_
!= x
.has_apicpumilliseconds_
: return 0
757 if self
.has_apicpumilliseconds_
and self
.apicpumilliseconds_
!= x
.apicpumilliseconds_
: return 0
758 if self
.has_apibytessent_
!= x
.has_apibytessent_
: return 0
759 if self
.has_apibytessent_
and self
.apibytessent_
!= x
.apibytessent_
: return 0
760 if self
.has_apibytesreceived_
!= x
.has_apibytesreceived_
: return 0
761 if self
.has_apibytesreceived_
and self
.apibytesreceived_
!= x
.apibytesreceived_
: return 0
764 def IsInitialized(self
, debug_strs
=None):
766 if (not self
.has_statuscode_
):
768 if debug_strs
is not None:
769 debug_strs
.append('Required field: statuscode not set.')
770 for p
in self
.header_
:
771 if not p
.IsInitialized(debug_strs
): initialized
=0
776 if (self
.has_content_
): n
+= 1 + self
.lengthString(len(self
.content_
))
777 n
+= self
.lengthVarInt64(self
.statuscode_
)
778 n
+= 2 * len(self
.header_
)
779 for i
in xrange(len(self
.header_
)): n
+= self
.header_
[i
].ByteSize()
780 if (self
.has_contentwastruncated_
): n
+= 2
781 if (self
.has_externalbytessent_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytessent_
)
782 if (self
.has_externalbytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.externalbytesreceived_
)
783 if (self
.has_finalurl_
): n
+= 1 + self
.lengthString(len(self
.finalurl_
))
784 if (self
.has_apicpumilliseconds_
): n
+= 1 + self
.lengthVarInt64(self
.apicpumilliseconds_
)
785 if (self
.has_apibytessent_
): n
+= 1 + self
.lengthVarInt64(self
.apibytessent_
)
786 if (self
.has_apibytesreceived_
): n
+= 1 + self
.lengthVarInt64(self
.apibytesreceived_
)
791 self
.clear_statuscode()
793 self
.clear_contentwastruncated()
794 self
.clear_externalbytessent()
795 self
.clear_externalbytesreceived()
796 self
.clear_finalurl()
797 self
.clear_apicpumilliseconds()
798 self
.clear_apibytessent()
799 self
.clear_apibytesreceived()
801 def OutputUnchecked(self
, out
):
802 if (self
.has_content_
):
804 out
.putPrefixedString(self
.content_
)
806 out
.putVarInt32(self
.statuscode_
)
807 for i
in xrange(len(self
.header_
)):
809 self
.header_
[i
].OutputUnchecked(out
)
811 if (self
.has_contentwastruncated_
):
813 out
.putBoolean(self
.contentwastruncated_
)
814 if (self
.has_externalbytessent_
):
816 out
.putVarInt64(self
.externalbytessent_
)
817 if (self
.has_externalbytesreceived_
):
819 out
.putVarInt64(self
.externalbytesreceived_
)
820 if (self
.has_finalurl_
):
822 out
.putPrefixedString(self
.finalurl_
)
823 if (self
.has_apicpumilliseconds_
):
825 out
.putVarInt64(self
.apicpumilliseconds_
)
826 if (self
.has_apibytessent_
):
828 out
.putVarInt64(self
.apibytessent_
)
829 if (self
.has_apibytesreceived_
):
831 out
.putVarInt64(self
.apibytesreceived_
)
833 def TryMerge(self
, d
):
837 self
.set_content(d
.getPrefixedString())
840 self
.set_statuscode(d
.getVarInt32())
843 self
.add_header().TryMerge(d
)
846 self
.set_contentwastruncated(d
.getBoolean())
849 self
.set_externalbytessent(d
.getVarInt64())
852 self
.set_externalbytesreceived(d
.getVarInt64())
855 self
.set_finalurl(d
.getPrefixedString())
858 self
.set_apicpumilliseconds(d
.getVarInt64())
861 self
.set_apibytessent(d
.getVarInt64())
864 self
.set_apibytesreceived(d
.getVarInt64())
866 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
870 def __str__(self
, prefix
="", printElemNumber
=0):
872 if self
.has_content_
: res
+=prefix
+("Content: %s\n" % self
.DebugFormatString(self
.content_
))
873 if self
.has_statuscode_
: res
+=prefix
+("StatusCode: %s\n" % self
.DebugFormatInt32(self
.statuscode_
))
875 for e
in self
.header_
:
877 if printElemNumber
: elm
="(%d)" % cnt
878 res
+=prefix
+("Header%s {\n" % elm
)
879 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
882 if self
.has_contentwastruncated_
: res
+=prefix
+("ContentWasTruncated: %s\n" % self
.DebugFormatBool(self
.contentwastruncated_
))
883 if self
.has_externalbytessent_
: res
+=prefix
+("ExternalBytesSent: %s\n" % self
.DebugFormatInt64(self
.externalbytessent_
))
884 if self
.has_externalbytesreceived_
: res
+=prefix
+("ExternalBytesReceived: %s\n" % self
.DebugFormatInt64(self
.externalbytesreceived_
))
885 if self
.has_finalurl_
: res
+=prefix
+("FinalUrl: %s\n" % self
.DebugFormatString(self
.finalurl_
))
886 if self
.has_apicpumilliseconds_
: res
+=prefix
+("ApiCpuMilliseconds: %s\n" % self
.DebugFormatInt64(self
.apicpumilliseconds_
))
887 if self
.has_apibytessent_
: res
+=prefix
+("ApiBytesSent: %s\n" % self
.DebugFormatInt64(self
.apibytessent_
))
888 if self
.has_apibytesreceived_
: res
+=prefix
+("ApiBytesReceived: %s\n" % self
.DebugFormatInt64(self
.apibytesreceived_
))
892 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
893 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
900 kContentWasTruncated
= 6
901 kExternalBytesSent
= 7
902 kExternalBytesReceived
= 8
904 kApiCpuMilliseconds
= 10
906 kApiBytesReceived
= 12
908 _TEXT
= _BuildTagLookupTable({
915 6: "ContentWasTruncated",
916 7: "ExternalBytesSent",
917 8: "ExternalBytesReceived",
919 10: "ApiCpuMilliseconds",
921 12: "ApiBytesReceived",
924 _TYPES
= _BuildTagLookupTable({
925 0: ProtocolBuffer
.Encoder
.NUMERIC
,
926 1: ProtocolBuffer
.Encoder
.STRING
,
927 2: ProtocolBuffer
.Encoder
.NUMERIC
,
928 3: ProtocolBuffer
.Encoder
.STARTGROUP
,
929 4: ProtocolBuffer
.Encoder
.STRING
,
930 5: ProtocolBuffer
.Encoder
.STRING
,
931 6: ProtocolBuffer
.Encoder
.NUMERIC
,
932 7: ProtocolBuffer
.Encoder
.NUMERIC
,
933 8: ProtocolBuffer
.Encoder
.NUMERIC
,
934 9: ProtocolBuffer
.Encoder
.STRING
,
935 10: ProtocolBuffer
.Encoder
.NUMERIC
,
936 11: ProtocolBuffer
.Encoder
.NUMERIC
,
937 12: ProtocolBuffer
.Encoder
.NUMERIC
,
938 }, 12, ProtocolBuffer
.Encoder
.MAX_TYPE
)
941 _STYLE_CONTENT_TYPE
= """"""
943 __all__
= ['URLFetchServiceError','URLFetchRequest','URLFetchRequest_Header','URLFetchResponse','URLFetchResponse_Header']