Refacto for XML parsing.

Previously, the parser was rather raw: we processed the buffer bytes by bytes, checking if the buffer was a valid XML file.
Now, we use libxml SAX parser to detect the end of the XML.
This commit is contained in:
jcamiel 2023-09-09 16:52:11 +02:00 committed by hurl-bot
parent b1bb431772
commit f82ed05d9a
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
8 changed files with 1395 additions and 62 deletions

24
Cargo.lock generated
View File

@ -563,8 +563,8 @@ name = "hurl_core"
version = "4.1.0-SNAPSHOT"
dependencies = [
"float-cmp",
"libxml",
"regex",
"sxd-document",
]
[[package]]
@ -810,12 +810,6 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]]
name = "peresil"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f658886ed52e196e850cfbbfddab9eaa7f6d90dd0929e264c31e5cec07e09e57"
[[package]]
name = "pkg-config"
version = "0.3.27"
@ -1091,16 +1085,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "sxd-document"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94d82f37be9faf1b10a82c4bd492b74f698e40082f0f40de38ab275f31d42078"
dependencies = [
"peresil",
"typed-arena",
]
[[package]]
name = "syn"
version = "2.0.32"
@ -1171,12 +1155,6 @@ dependencies = [
"serde",
]
[[package]]
name = "typed-arena"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
[[package]]
name = "typenum"
version = "1.16.0"

View File

@ -1,2 +0,0 @@
curl 'http://localhost:8000/post-xml' --header 'Content-Type: application/xml' --data $'<?xml version="1.0"?>\n<drink>café</drink>'
curl 'http://localhost:8000/post-xml-no-prolog' --header 'Content-Type: application/xml' --data '<drink>café</drink>'

View File

@ -1,15 +1,626 @@
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># POST the following XML</span>
<span class="line"></span><span class="comment"># &lt;?xml version="1.0"?&gt;</span>
<span class="line"></span><span class="comment"># &lt;drink&gt;café&lt;/drink&gt;</span>
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/post-xml</span></span>
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/post-xml</span></span>
<span class="xml"><span class="line">&lt;?xml version="1.0"?&gt;</span>
<span class="line">&lt;drink&gt;café&lt;/drink&gt;</span></span>
</span><span class="response"><span class="line"></span>
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/post-xml-no-prolog</span></span>
<span class="xml"><span class="line">&lt;drink&gt;café&lt;/drink&gt;</span></span>
</span><span class="response"><span class="line"></span>
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/post-xml-large</span></span>
<span class="xml"><span class="line">&lt;?xml version='1.0' ?&gt;</span>
<span class="line">&lt;root&gt;</span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;MH of San Francisco,&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;</span>
<span class="line"> 8</span>
<span class="line"> &lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;$9&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;$10&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;Mon Nov 27, 2:00 pm PT&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;</span>
<span class="line"> 3699803</span>
<span class="line"> &lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> $2459</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;1&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;</span>
<span class="line"> 900MHz</span>
<span class="line"> &lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;HP Pavilion&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;The Pavilion 9780C gives you</span>
<span class="line"> everything you need in a home</span>
<span class="line"> PC, from the exhilarating</span>
<span class="line"> multimedia experience of DVD to</span>
<span class="line"> the customized music-making</span>
<span class="line"> abilities of the HP CD-Writer</span>
<span class="line"> Plus - it's all in a hot</span>
<span class="line"> translucent blue case! Monitor</span>
<span class="line"> not included.</span>
<span class="line"></span>
<span class="line"></span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;tx of Santa Clara&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;2&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;Mon Nov 27, 2:30 pm PT&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;</span>
<span class="line"> 3699948</span>
<span class="line"> &lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> $3837</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;2&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;128MB high-performance PC133 ECC SDRAM Maximum: 4GB memory</span>
<span class="line"> capacity (3.3GB maximum usable memory)</span>
<span class="line"> &lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;Open bay - none installed or includedSupports 9.1GB and 18.2GB 7,200rpm Ultra2</span>
<span class="line"> SCSI disk drivesSupports 9.1GB, 18.2GB, and 36.4GB 10,000rpm Ultra2 SCSI disk</span>
<span class="line"> drives</span>
<span class="line"> &lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;Intel Pentium III 800MHz&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;Hewlett Packard NetServer LH3000 Pentium III 800MHz</span>
<span class="line"> 128MB RAM/Open Bay/32X CD/No OS</span>
<span class="line"> &lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> HP NetServer LH 3000 Pentium III 800MHzThis rack mount HP</span>
<span class="line"> NetServer LH 3000 brings higher performance and reliability to</span>
<span class="line"> meet your demanding departmental server requirements.</span>
<span class="line"> Incorporating performance, storage, and high-availability</span>
<span class="line"> technologies, this workhorse is loaded with features you'd</span>
<span class="line"> expect only in high-end servers.Key Features At a Glance:</span>
<span class="line"> Extraordinary performance -- dual Intel Pentium III processor</span>
<span class="line"> capability (one 800MHz processor included)- with 133MHz front</span>
<span class="line"> side bus, PC 133MHz ECC SDRAM, and performance-boosting</span>
<span class="line"> integrated RAID controller. Best-in-class reliability and</span>
<span class="line"> uptime -- with fully hot-swappable/hot-pluggable components,</span>
<span class="line"> including disk drives, power supplies, fans, and hot-plug PCI</span>
<span class="line"> slots. Includes widely adopted, fault-tolerant RAID 5</span>
<span class="line"> technology-using an embedded, dual-channel NetRAID controller</span>
<span class="line"> with optional battery backup, hardware-based parity (XOR)</span>
<span class="line"> logic, and 32MB cache-expandable to 128MB. Excellent</span>
<span class="line"> investment protection -- the HP NetServer LH 3000's design</span>
<span class="line"> makes it easily upgradable as higher scalability Xeon servers</span>
<span class="line"> and new processor enhancements become available. HP OpenView</span>
<span class="line"> ManageX Event Manager -- for simplified NOS and high</span>
<span class="line"> availability system management. Intelligent management -- a</span>
<span class="line"> comprehensive tool set to monitor your server hardware and</span>
<span class="line"> software from anywhere, anytime. Simple installation-rack</span>
<span class="line"> mount form factor version.</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;LW of Sugar Land&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;1&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;</span>
<span class="line"> $9</span>
<span class="line"> &lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;</span>
<span class="line"> $20</span>
<span class="line"> &lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;</span>
<span class="line"> Mon Nov 27, 2:30 pm PT</span>
<span class="line"> &lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;3699893&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;$2392</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;Hewlett Packard NetServe&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;Refurbished and warranted by</span>
<span class="line"> manufacturer! Dual processing</span>
<span class="line"> capability (one 800MHz Pentium</span>
<span class="line"> III processor provided)!!!</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;BT of Los Angeles&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;2&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;$9&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;$20&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;Mon Nov 27, 2:30 pm PT&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;</span>
<span class="line"> 3699928</span>
<span class="line"> &lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> $2475</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;AM memory</span>
<span class="line"> expandable to 4GB (128MB</span>
<span class="line"> provided)</span>
<span class="line"> &lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;800MHz Pentium III processor&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;Dual processing capability(one</span>
<span class="line"> 800MHz Pentium III processor</span>
<span class="line"> providedd)!! RAM memory</span>
<span class="line"> expandable to 4GB (128MB</span>
<span class="line"> provided)!! Refurbished and</span>
<span class="line"> warranted by manufacturer!!HP NetServer LC 2000 Pentium III 800MHz -- The rock-solid</span>
<span class="line"> workgroup server your growing business can depend on --This HP</span>
<span class="line"> NetServer LC 2000 offers an innovative solution that delivers</span>
<span class="line"> top quality to corporate workgroups, branch offices and</span>
<span class="line"> quickly-growing small businesses with: High tech and high</span>
<span class="line"> touch -- designed to be simple to install, configure and</span>
<span class="line"> upgrade, all HP NetServer LC 2000 components are easily</span>
<span class="line"> accessible and designed for tool-less service -- accented by</span>
<span class="line"> color-coded "touch points" High availability -- created to</span>
<span class="line"> deliver the most essential uptime-protecting technologies to</span>
<span class="line"> meet your computing needs. With more hot-swappable and</span>
<span class="line"> redundant components in a workgroup server, the LC 2000</span>
<span class="line"> creates a super-reliable foundation for the growing network</span>
<span class="line"> Intelligent management -- the HP NetServer LC 2000 is</span>
<span class="line"> complemented by a hardware and NOS management suite that</span>
<span class="line"> combines unmatched flexibility with simplicity for precise</span>
<span class="line"> control. HP management tools ensure that your workgroup and</span>
<span class="line"> remote office IT professionals can manage the LC 2000 from any</span>
<span class="line"> location. Best-in-class uptime protection -- with up to six</span>
<span class="line"> hot-swappable disk drive bays, standard redundant,</span>
<span class="line"> hot-swappable fans, optional hot-swappable redundant power</span>
<span class="line"> supplies, support for redundant NICS, and duplexing Freedom</span>
<span class="line"> to expand -- with dual processing capability (one 800MHz</span>
<span class="line"> Pentium III processor provided), capacity for up to 4GB SDRAM</span>
<span class="line"> (128MB standard), expandable storage capability and six open</span>
<span class="line"> PCI slots, the HP NetServer LC 2000 offers room for growth</span>
<span class="line"> that is unprecedented in a workgroup serverThis LC 2000</span>
<span class="line"> provides top quality in a server for corporate workgroups,</span>
<span class="line"> branch offices and quickly growing small businesses that want</span>
<span class="line"> enterprise-level system reliability features. Designed with</span>
<span class="line"> simplicity for easy installation, the HP NetServer LC 2000</span>
<span class="line"> meets the demands of your quickly growing business today and</span>
<span class="line"> offers the capability to expand as your workplace computing</span>
<span class="line"> needs increase in the</span>
<span class="line"> future.********************************** -- F E A T U R E S A</span>
<span class="line"> T A GLANCE --PROCESSOR:One Intel Pentium III 800MHz (dual</span>
<span class="line"> capability with upgrade) with 133MHz front-side bus256K on-die</span>
<span class="line"> write-back cacheMEMORY: Standard: 128MB SDRAM PC-133 DIMM per</span>
<span class="line"> slotMaximum: 4GB Four DIMM sockets HARD DISK DRIVE : Open</span>
<span class="line"> baySTORAGE : Diskette drive: 3.5" 1.44MBCD-ROM drive: Maximum</span>
<span class="line"> 32X IDENETWORK CONTROLLER:Integrated 10/100TX NIC (supports</span>
<span class="line"> redundant NICs)BUS SPEED:133MHz front-side bus EXPANSION</span>
<span class="line"> SLOTS:Two 64-bit and four 32-bit PCI slotsPeer 32-bit/64-bit</span>
<span class="line"> PCI buses, both at 33MHzPORTS:One serial portOne 25-pin</span>
<span class="line"> parallel portOne SCSI knockout port for external</span>
<span class="line"> connectionsOne server management port (serial)Video</span>
<span class="line"> port-SVGAMini-DIN keyboard and mouse portsSTORAGE</span>
<span class="line"> CONTROLLER:Embedded dual channel Ultra-2 SCSIVIDEO:Embedded</span>
<span class="line"> ATI Rage IIc video controller1024x768, 64K color at 75Hz2MB</span>
<span class="line"> SGRAMPOWER SUPPLY:349 Watts (Nominal, 100-127/200-240V AC,</span>
<span class="line"> 50/60Hz; range, 90-140/180-264V AC, 47/63Hz)FORM</span>
<span class="line"> 648mm (25.5") without bezelOPERATING SYSTEM:None installed or</span>
<span class="line"> includedOPTIONAL OPERATING SYSTEMS SUPPORTED:Microsoft Windows</span>
<span class="line"> NT 4.0Windows2000Novell NetWare 4.2, 5.0Red Hat LinuxSCO</span>
<span class="line"> OpenServerUnixWare****************************************HP</span>
<span class="line"> NetServer LC 2000 -- the rock-solid workgroup server your</span>
<span class="line"> growing business can depend on!</span>
<span class="line"></span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;RP of Cleveland&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;1&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;$9&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;</span>
<span class="line"> $10</span>
<span class="line"> &lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;Mon Nov 27, 3:00 pm PT&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;</span>
<span class="line"> 3697285</span>
<span class="line"> &lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;$3000</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;28MB PC133 SDRAM 168-Pin Memory, 3.3 volt Non-ECC, Non-Buffered, 7.5ns</span>
<span class="line"> Speed</span>
<span class="line"> &lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;30GB 7200 RPM IDE Hard Drive with UltraDMA 66 interface to ensure maximum data</span>
<span class="line"> throughput</span>
<span class="line"> &lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;III 800MHz Processor with 133MHz Bus&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;Elite PC PIII 800MHz 128MB RAM 30GB HD 10X DVD</span>
<span class="line"> 32MB VID/56K/NIC/3D SND/No OS</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line"></span>
<span class="line"> &lt;listing&gt;</span>
<span class="line"> &lt;seller_info&gt;</span>
<span class="line"> &lt;seller_name&gt;&lt;/seller_name&gt;</span>
<span class="line"> &lt;seller_rating&gt;&lt;/seller_rating&gt;</span>
<span class="line"> &lt;/seller_info&gt;</span>
<span class="line"> &lt;payment_types&gt;</span>
<span class="line"> &lt;/payment_types&gt;</span>
<span class="line"> &lt;shipping_info&gt;</span>
<span class="line"> &lt;/shipping_info&gt;</span>
<span class="line"> &lt;buyer_protection_info&gt;</span>
<span class="line"> &lt;/buyer_protection_info&gt;</span>
<span class="line"> &lt;auction_info&gt;</span>
<span class="line"> &lt;current_bid&gt;&lt;/current_bid&gt;</span>
<span class="line"> &lt;time_left&gt;&lt;/time_left&gt;</span>
<span class="line"> &lt;high_bidder&gt;</span>
<span class="line"> &lt;bidder_name&gt;&lt;/bidder_name&gt;</span>
<span class="line"> &lt;bidder_rating&gt;&lt;/bidder_rating&gt;</span>
<span class="line"> &lt;/high_bidder&gt;</span>
<span class="line"> &lt;num_items&gt;&lt;/num_items&gt;</span>
<span class="line"> &lt;num_bids&gt;&lt;/num_bids&gt;</span>
<span class="line"> &lt;started_at&gt;&lt;/started_at&gt;</span>
<span class="line"> &lt;bid_increment&gt;&lt;/bid_increment&gt;</span>
<span class="line"> &lt;location&gt;&lt;/location&gt;</span>
<span class="line"> &lt;opened&gt;&lt;/opened&gt;</span>
<span class="line"> &lt;closed&gt;&lt;/closed&gt;</span>
<span class="line"> &lt;id_num&gt;&lt;/id_num&gt;</span>
<span class="line"> &lt;notes&gt;&lt;/notes&gt;</span>
<span class="line"> &lt;/auction_info&gt;</span>
<span class="line"> &lt;bid_history&gt;</span>
<span class="line"> &lt;highest_bid_amount&gt;</span>
<span class="line"> &lt;/highest_bid_amount&gt;</span>
<span class="line"> &lt;quantity&gt;&lt;/quantity&gt;</span>
<span class="line"> &lt;/bid_history&gt;</span>
<span class="line"> &lt;item_info&gt;</span>
<span class="line"> &lt;memory&gt;&lt;/memory&gt;</span>
<span class="line"> &lt;hard_drive&gt;&lt;/hard_drive&gt;</span>
<span class="line"> &lt;cpu&gt;&lt;/cpu&gt;</span>
<span class="line"> &lt;brand&gt;&lt;/brand&gt;</span>
<span class="line"> &lt;description&gt;</span>
<span class="line"> &lt;/description&gt;</span>
<span class="line"> &lt;/item_info&gt;</span>
<span class="line"> &lt;/listing&gt;</span>
<span class="line">&lt;/root&gt;</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span></span></code></pre>

View File

@ -1,14 +1,625 @@
# POST the following XML
# <?xml version="1.0"?>
# <drink>café</drink>
POST http://localhost:8000/post-xml
<?xml version="1.0"?>
<drink>café</drink>
HTTP 200
POST http://localhost:8000/post-xml-no-prolog
<drink>café</drink>
HTTP 200
POST http://localhost:8000/post-xml-large
<?xml version='1.0' ?>
<root>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name>MH of San Francisco,</bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items>
8
</num_items>
<num_bids></num_bids>
<started_at>$9</started_at>
<bid_increment>$10</bid_increment>
<location></location>
<opened></opened>
<closed>Mon Nov 27, 2:00 pm PT</closed>
<id_num>
3699803
</id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
$2459
</highest_bid_amount>
<quantity>1</quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu>
900MHz
</cpu>
<brand>HP Pavilion</brand>
<description>The Pavilion 9780C gives you
everything you need in a home
PC, from the exhilarating
multimedia experience of DVD to
the customized music-making
abilities of the HP CD-Writer
Plus - it's all in a hot
translucent blue case! Monitor
not included.
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name>tx of Santa Clara</seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items>2</num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed>Mon Nov 27, 2:30 pm PT</closed>
<id_num>
3699948
</id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
$3837
</highest_bid_amount>
<quantity>2</quantity>
</bid_history>
<item_info>
<memory>128MB high-performance PC133 ECC SDRAM Maximum: 4GB memory
capacity (3.3GB maximum usable memory)
</memory>
<hard_drive>Open bay - none installed or includedSupports 9.1GB and 18.2GB 7,200rpm Ultra2
SCSI disk drivesSupports 9.1GB, 18.2GB, and 36.4GB 10,000rpm Ultra2 SCSI disk
drives
</hard_drive>
<cpu>Intel Pentium III 800MHz</cpu>
<brand>Hewlett Packard NetServer LH3000 Pentium III 800MHz
128MB RAM/Open Bay/32X CD/No OS
</brand>
<description>
HP NetServer LH 3000 Pentium III 800MHzThis rack mount HP
NetServer LH 3000 brings higher performance and reliability to
meet your demanding departmental server requirements.
Incorporating performance, storage, and high-availability
technologies, this workhorse is loaded with features you'd
expect only in high-end servers.Key Features At a Glance:
Extraordinary performance -- dual Intel Pentium III processor
capability (one 800MHz processor included)- with 133MHz front
side bus, PC 133MHz ECC SDRAM, and performance-boosting
integrated RAID controller. Best-in-class reliability and
uptime -- with fully hot-swappable/hot-pluggable components,
including disk drives, power supplies, fans, and hot-plug PCI
slots. Includes widely adopted, fault-tolerant RAID 5
technology-using an embedded, dual-channel NetRAID controller
with optional battery backup, hardware-based parity (XOR)
logic, and 32MB cache-expandable to 128MB. Excellent
investment protection -- the HP NetServer LH 3000's design
makes it easily upgradable as higher scalability Xeon servers
and new processor enhancements become available. HP OpenView
ManageX Event Manager -- for simplified NOS and high
availability system management. Intelligent management -- a
comprehensive tool set to monitor your server hardware and
software from anywhere, anytime. Simple installation-rack
mount form factor version.
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name>LW of Sugar Land</bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items>1</num_items>
<num_bids></num_bids>
<started_at>
$9
</started_at>
<bid_increment>
$20
</bid_increment>
<location></location>
<opened></opened>
<closed>
Mon Nov 27, 2:30 pm PT
</closed>
<id_num>3699893</id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>$2392
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand>Hewlett Packard NetServe</brand>
<description>Refurbished and warranted by
manufacturer! Dual processing
capability (one 800MHz Pentium
III processor provided)!!!
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name>BT of Los Angeles</bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items>2</num_items>
<num_bids></num_bids>
<started_at>$9</started_at>
<bid_increment>$20</bid_increment>
<location></location>
<opened></opened>
<closed>Mon Nov 27, 2:30 pm PT</closed>
<id_num>
3699928
</id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
$2475
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory>AM memory
expandable to 4GB (128MB
provided)
</memory>
<hard_drive></hard_drive>
<cpu>800MHz Pentium III processor</cpu>
<brand></brand>
<description>Dual processing capability(one
800MHz Pentium III processor
providedd)!! RAM memory
expandable to 4GB (128MB
provided)!! Refurbished and
warranted by manufacturer!!HP NetServer LC 2000 Pentium III 800MHz -- The rock-solid
workgroup server your growing business can depend on --This HP
NetServer LC 2000 offers an innovative solution that delivers
top quality to corporate workgroups, branch offices and
quickly-growing small businesses with: High tech and high
touch -- designed to be simple to install, configure and
upgrade, all HP NetServer LC 2000 components are easily
accessible and designed for tool-less service -- accented by
color-coded "touch points" High availability -- created to
deliver the most essential uptime-protecting technologies to
meet your computing needs. With more hot-swappable and
redundant components in a workgroup server, the LC 2000
creates a super-reliable foundation for the growing network
Intelligent management -- the HP NetServer LC 2000 is
complemented by a hardware and NOS management suite that
combines unmatched flexibility with simplicity for precise
control. HP management tools ensure that your workgroup and
remote office IT professionals can manage the LC 2000 from any
location. Best-in-class uptime protection -- with up to six
hot-swappable disk drive bays, standard redundant,
hot-swappable fans, optional hot-swappable redundant power
supplies, support for redundant NICS, and duplexing Freedom
to expand -- with dual processing capability (one 800MHz
Pentium III processor provided), capacity for up to 4GB SDRAM
(128MB standard), expandable storage capability and six open
PCI slots, the HP NetServer LC 2000 offers room for growth
that is unprecedented in a workgroup serverThis LC 2000
provides top quality in a server for corporate workgroups,
branch offices and quickly growing small businesses that want
enterprise-level system reliability features. Designed with
simplicity for easy installation, the HP NetServer LC 2000
meets the demands of your quickly growing business today and
offers the capability to expand as your workplace computing
needs increase in the
future.********************************** -- F E A T U R E S A
T A GLANCE --PROCESSOR:One Intel Pentium III 800MHz (dual
capability with upgrade) with 133MHz front-side bus256K on-die
write-back cacheMEMORY: Standard: 128MB SDRAM PC-133 DIMM per
slotMaximum: 4GB Four DIMM sockets HARD DISK DRIVE : Open
baySTORAGE : Diskette drive: 3.5" 1.44MBCD-ROM drive: Maximum
32X IDENETWORK CONTROLLER:Integrated 10/100TX NIC (supports
redundant NICs)BUS SPEED:133MHz front-side bus EXPANSION
SLOTS:Two 64-bit and four 32-bit PCI slotsPeer 32-bit/64-bit
PCI buses, both at 33MHzPORTS:One serial portOne 25-pin
parallel portOne SCSI knockout port for external
connectionsOne server management port (serial)Video
port-SVGAMini-DIN keyboard and mouse portsSTORAGE
CONTROLLER:Embedded dual channel Ultra-2 SCSIVIDEO:Embedded
ATI Rage IIc video controller1024x768, 64K color at 75Hz2MB
SGRAMPOWER SUPPLY:349 Watts (Nominal, 100-127/200-240V AC,
50/60Hz; range, 90-140/180-264V AC, 47/63Hz)FORM
648mm (25.5") without bezelOPERATING SYSTEM:None installed or
includedOPTIONAL OPERATING SYSTEMS SUPPORTED:Microsoft Windows
NT 4.0Windows2000Novell NetWare 4.2, 5.0Red Hat LinuxSCO
OpenServerUnixWare****************************************HP
NetServer LC 2000 -- the rock-solid workgroup server your
growing business can depend on!
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name>RP of Cleveland</bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items>1</num_items>
<num_bids></num_bids>
<started_at>$9</started_at>
<bid_increment>
$10
</bid_increment>
<location></location>
<opened></opened>
<closed>Mon Nov 27, 3:00 pm PT</closed>
<id_num>
3697285
</id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>$3000
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory>28MB PC133 SDRAM 168-Pin Memory, 3.3 volt Non-ECC, Non-Buffered, 7.5ns
Speed
</memory>
<hard_drive>30GB 7200 RPM IDE Hard Drive with UltraDMA 66 interface to ensure maximum data
throughput
</hard_drive>
<cpu>III 800MHz Processor with 133MHz Bus</cpu>
<brand></brand>
<description>Elite PC PIII 800MHz 128MB RAM 30GB HD 10X DVD
32MB VID/56K/NIC/3D SND/No OS
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
<listing>
<seller_info>
<seller_name></seller_name>
<seller_rating></seller_rating>
</seller_info>
<payment_types>
</payment_types>
<shipping_info>
</shipping_info>
<buyer_protection_info>
</buyer_protection_info>
<auction_info>
<current_bid></current_bid>
<time_left></time_left>
<high_bidder>
<bidder_name></bidder_name>
<bidder_rating></bidder_rating>
</high_bidder>
<num_items></num_items>
<num_bids></num_bids>
<started_at></started_at>
<bid_increment></bid_increment>
<location></location>
<opened></opened>
<closed></closed>
<id_num></id_num>
<notes></notes>
</auction_info>
<bid_history>
<highest_bid_amount>
</highest_bid_amount>
<quantity></quantity>
</bid_history>
<item_info>
<memory></memory>
<hard_drive></hard_drive>
<cpu></cpu>
<brand></brand>
<description>
</description>
</item_info>
</listing>
</root>
HTTP 200

File diff suppressed because one or more lines are too long

View File

@ -19,3 +19,10 @@ def post_xml_no_prolog():
s = request.data.decode("utf-8")
assert s == """<drink>caf\u00e9</drink>"""
return ""
@app.route("/post-xml-large", methods=["POST"])
def post_xml_large():
s = request.data.decode("utf-8")
assert len(s) == 22156
return ""

View File

@ -16,5 +16,5 @@ strict = []
[dependencies]
float-cmp = "0.9.0"
sxd-document = "0.3.2"
libxml = "0.3.3"
regex = "1.9.5"

View File

@ -15,54 +15,182 @@
* limitations under the License.
*
*/
use sxd_document::parser;
use libxml::bindings::{
xmlChar, xmlCreatePushParserCtxt, xmlFreeParserCtxt, xmlParseChunk, xmlSAXHandlerPtr,
};
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;
use crate::ast::Pos;
use crate::parser::error::*;
use crate::parser::reader::Reader;
use crate::parser::ParseResult;
pub fn parse(reader: &mut Reader) -> ParseResult<String> {
let mut buf = String::new();
let start = reader.state.clone();
match reader.read() {
Some('<') => buf.push('<'),
// We test if our first character is a start of an XML text.
// If not, we return immediately a recoverable error.
// Otherwise, we start parsing the supposedly XML buffer. Any
// subsequent error will be a non recoverable error.
let c = reader.peek();
match c {
Some('<') => {}
_ => {
return Err(Error {
pos: Pos { line: 1, column: 1 },
pos: start.pos,
recoverable: true,
inner: ParseError::Xml,
})
}
}
loop {
match reader.read() {
None => {
let mut buf = String::new();
let mut parser = new_sax_parser();
let mut parser_context = ParserContext::new();
// We use libxml SAX parser to identify the end of the XML body.
// We feed the SAX parser chars by chars (Rust char), so chunks are UFT-8 bytes,
// 1 byte to 4 bytes long. The detection of the body end is done when receiving a closing
// element event by testing the depth of the XML tree.
unsafe {
let context = xmlCreatePushParserCtxt(
&mut parser as xmlSAXHandlerPtr,
&mut parser_context as *mut ParserContext as *mut c_void,
ptr::null(),
0,
ptr::null(),
);
while let Some(c) = reader.read() {
buf.push(c);
// We feed the parser chars by chars.
// A buffer of length four is large enough to encode any char.
let mut bytes = [0u8; 4];
let end = reader.is_eof() as c_int;
let bytes = c.encode_utf8(&mut bytes);
let count = bytes.len() as c_int;
let bytes = bytes.as_ptr() as *const c_char;
let ret = xmlParseChunk(context, bytes, count, end);
if ret != 0 {
xmlFreeParserCtxt(context);
return Err(Error {
pos: start.pos,
recoverable: false,
inner: ParseError::Xml,
});
}
// End of the XML body is detected with a closing element event and depth of the tree.
// There is also a closing document event but it's not always raised at the exact
// closing `>` position.
if std::matches!(parser_context.state, ParserState::EndElement)
&& parser_context.depth == 0
{
break;
}
Some(c) => {
buf.push(c);
if c == '>' && is_valid(buf.as_str()) {
return Ok(buf);
}
}
}
xmlFreeParserCtxt(context);
}
Err(Error {
pos: start.pos,
recoverable: false,
inner: ParseError::Xml,
})
Ok(buf)
}
fn is_valid(s: &str) -> bool {
parser::parse(s).is_ok()
/// A context for the SAX parser, containing a `state` and the current tree `depth`.
struct ParserContext {
depth: usize,
state: ParserState,
}
impl ParserContext {
fn new() -> ParserContext {
ParserContext {
depth: 0,
state: ParserState::Created,
}
}
}
enum ParserState {
Created,
StartDocument,
EndDocument,
StartElement,
EndElement,
}
fn new_sax_parser() -> libxml::bindings::xmlSAXHandler {
libxml::bindings::xmlSAXHandler {
internalSubset: None,
isStandalone: None,
hasInternalSubset: None,
hasExternalSubset: None,
resolveEntity: None,
getEntity: None,
entityDecl: None,
notationDecl: None,
attributeDecl: None,
elementDecl: None,
unparsedEntityDecl: None,
setDocumentLocator: None,
startDocument: Some(on_start_document),
endDocument: Some(on_end_document),
startElement: Some(on_start_element),
endElement: Some(on_end_element),
reference: None,
characters: None,
ignorableWhitespace: None,
processingInstruction: None,
comment: None,
warning: None,
error: None,
fatalError: None,
getParameterEntity: None,
cdataBlock: None,
externalSubset: None,
initialized: libxml::bindings::XML_SAX2_MAGIC,
_private: ptr::null_mut(),
startElementNs: None,
endElementNs: None,
serror: None,
}
}
/// Called when the document start being processed.
unsafe extern "C" fn on_start_document(ctx: *mut c_void) {
let context: &mut ParserContext = unsafe { &mut *(ctx as *mut ParserContext) };
context.state = ParserState::StartDocument;
}
/// Called when the document end has been detected.
unsafe extern "C" fn on_end_document(ctx: *mut c_void) {
let context: &mut ParserContext = unsafe { &mut *(ctx as *mut ParserContext) };
context.state = ParserState::EndDocument;
}
/// Called when an opening tag has been processed.
unsafe extern "C" fn on_start_element(
ctx: *mut c_void,
_name: *const xmlChar,
_atts: *mut *const xmlChar,
) {
let context: &mut ParserContext = unsafe { &mut *(ctx as *mut ParserContext) };
context.state = ParserState::StartElement;
context.depth += 1;
}
/// Called when the end of an element has been detected.
unsafe extern "C" fn on_end_element(ctx: *mut c_void, _name: *const xmlChar) {
let context: &mut ParserContext = unsafe { &mut *(ctx as *mut ParserContext) };
context.state = ParserState::EndElement;
context.depth -= 1;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::ast::Pos;
#[test]
fn parse_xml_brute_force_errors() {