Changeset 89fe6da for server/lib/ipprequest.py
- Timestamp:
- Mar 5, 2011, 5:33:55 PM (14 years ago)
- Branches:
- no-cups
- Children:
- 574aee4
- Parents:
- aaa1da3
- git-author:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 17:33:55)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 17:33:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/ipprequest.py
raaa1da3 r89fe6da 420 420 # can be read from to get the request 421 421 def __init__(self, version=None, operation_id=None, request_id=None, 422 attribute_groups=[], data=None, request=None ):422 attribute_groups=[], data=None, request=None, length=sys.maxint): 423 423 """ 424 424 Create an IPPRequest. Takes either the segments of the … … 469 469 # read the version-number (two signed chars) 470 470 self.version = struct.unpack('>bb', request.read(2)) 471 length -= 2 471 472 logger.debug("version-number : (0x%X, 0x%X)" % self.version) 472 473 … … 474 475 # for a response) (signed short) 475 476 self.operation_id = struct.unpack('>h', request.read(2))[0] 477 length -= 2 476 478 logger.debug("operation-id : 0x%X" % self.operation_id) 477 479 478 480 # read the request-id (signed int) 479 481 self.request_id = struct.unpack('>i', request.read(4))[0] 482 length -= 4 480 483 logger.debug("request-id : 0x%X" % self.request_id) 481 484 … … 486 489 # read in the next byte 487 490 next_byte = struct.unpack('>b', request.read(1))[0] 491 length -=1 488 492 logger.debug("next byte : 0x%X" % next_byte) 489 493 … … 498 502 499 503 next_byte = struct.unpack('>b', request.read(1))[0] 504 length -= 1 500 505 logger.debug("next byte : 0x%X" % next_byte) 501 506 … … 508 513 # read in the length of the name (signed short) 509 514 name_length = struct.unpack('>h', request.read(2))[0] 515 length -= 2 510 516 logger.debug("name-length : %i" % name_length) 511 517 … … 513 519 # read the name (a string of name_length bytes) 514 520 name = request.read(name_length) 521 length -= name_length 515 522 logger.debug("name : %s" % name) 516 523 517 524 # read in the length of the value (signed short) 518 525 value_length = struct.unpack('>h', request.read(2))[0] 526 length -= 2 519 527 logger.debug("value-length : %i" % value_length) 520 528 521 529 # read in the value (string of value_length bytes) 522 530 value = request.read(value_length) 523 531 length -= value_length 532 524 533 ippvalue = IPPValue(value_tag, value) 525 534 logger.debug("value : %s" % ippvalue.value) … … 532 541 # read in the length of the value (signed short) 533 542 value_length = struct.unpack('>h', request.read(2))[0] 543 length -= 2 534 544 logger.debug("value-length : %i" % value_length) 535 545 536 546 # read in the value (string of value_length bytes) 537 547 value = request.read(value_length) 548 length -= value_length 538 549 539 550 ippvalue = IPPValue(value_tag, value) … … 545 556 # read another byte 546 557 next_byte = struct.unpack('>b', request.read(1))[0] 558 length -= 1 547 559 548 560 self.attribute_groups.append(IPPAttributeGroup(attribute_group_tag, attributes)) … … 550 562 # once we hit the end-of-attributes tag, the only thing 551 563 # left is the data, so go ahead and read all of it 552 self.data = request.read() 564 assert length >= 0 565 self.data = request.read(length) 553 566 logger.debug("data : %s" % self.data) 554 567
Note: See TracChangeset
for help on using the changeset viewer.