Comments (4)
Please note that 204 No Content, and others have no body either.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
"For response messages, whether or not a message-body is included with
a message is dependent on both the request method and the response
status code (section 6.1.1). All responses to the HEAD request method
MUST NOT include a message-body, even though the presence of entity-
header fields might lead one to believe they do. All 1xx
(informational), 204 (no content), and 304 (not modified) responses
MUST NOT include a message-body. All other responses do include a
message-body, although it MAY be of zero length."
Original comment by [email protected]
on 28 Sep 2010 at 2:32
from dpkt.
Ok. The current issue is being caused by dpkt reading the rest of the data into
the body if the response header has a content-type header, which is wrong
according to the RFC. A simple fix is simply to remove those two lines.
Of course, this doesn't solve the larger issue. Making the response
intelligently decide whether to parse a body is tricky with dpkt's
architecture, because the parsing of the body and headers is done in the
http.Message superclass.
Original comment by [email protected]
on 28 Sep 2010 at 5:45
from dpkt.
Attached is a patch to fix the issue:
1. Ignore content-type, as it does not say anything about the existence of a
body.
2. Do not attempt to read body if response status code is 1xx, 204 or 304.
3. Here comes the ugly part: ignore body if parameter head_response=True has
been passed to Response object. HEAD responses are identical to GET responses
(including Content-Length), except for the missing body. dpkt can not determine
automatically whether this is a HEAD response.
Also attached modified dpkt_http_bug2.zip:
- dpkt_bug.py: call dpkt.http.Response(data, head_response=True)
- stream.txt: file ends with '\r\n\r\n' (instead of '\r\n')
Original comment by [email protected]
on 10 Jan 2014 at 5:11
Attachments:
from dpkt.
Slight improvement: set body consistently to '' (empty string), avoid None.
Original comment by [email protected]
on 12 Jan 2014 at 12:32
Attachments:
from dpkt.
Related Issues (20)
- [patch] dns.unpack_name improvements
- Common DNS RR types missing (patch included)
- FCS field on dpkt.ethernet.Ethernet HOT 4
- ssl.py TLSMultiFactory recursion causes stack overflow HOT 2
- IEEE80211 - Management Frame Subtype Support HOT 11
- IEEE 802.11 Packets - Random Parsing Crashing HOT 2
- cannot install HOT 3
- Example Request - Control Type Packets - Destination/Source Addresses HOT 4
- Unsupported Control Packet Subtypes HOT 3
- Time stamp problem in dpkt HOT 3
- ip total length header field not stored correctly
- Patch for /trunk/dpkt/pcap.py
- IPv6 doesn't handle ESP packets sanely
- multiple IPv6 extension headers of the same type aren't handled
- time and size of packet HOT 3
- Contents of the pkt is cut
- Record Fragmentation not handled in TLSMultiFactory(buf)
- lldp parser should stop at end tlv HOT 1
- [patch] Made http.py return ordered headers
- Check if a given dpkt-layer is part of the packet
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dpkt.