Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(70)

Issue 13486044: HTTP Header

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 7 months ago by saulodamata
Modified:
10 years, 6 months ago
Reviewers:
Peter Barnes
CC:
ns-3-reviews_googlegroups.com
Visibility:
Public.

Description

An HTTP Header to send/receive HTTP messages. The implementation is based on real HTTP messages with status line and header fields.

Patch Set 1 #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+576 lines, -0 lines) Patch
A src/internet/model/http-header.h View 1 chunk +207 lines, -0 lines 2 comments Download
A src/internet/model/http-header.cc View 1 chunk +367 lines, -0 lines 5 comments Download
M src/internet/wscript View 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 1
Peter Barnes
10 years, 6 months ago (2013-10-01 23:10:17 UTC) #1
The patch is pretty clean; just a few issues commented inline.

The bigger problem is it needs some examples and a documentation section for the
ns-3 Model Library.

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header.cc
File src/internet/model/http-header.cc (right):

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.cc:132: m_headerFieldMap.insert
(std::pair<std::string, std::string>(headerFieldName, headerFieldValue));
Here you don't check for prior insertion of headerFieldName; in the other
SetHeaderField(string, uint32_t), you do check, and rewrite the value. 
Shouldn't you be doing the same here?

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.cc:194: os << "\nmethod:" << m_method << " "
Usually it's best to let the caller control leading white space, instead of hard
coding a "\n" at the beginning of your output.  (The caller might need this
output on the same line as his preamble, such as a timestamp...)

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.cc:250: std::string requestLine = m_method + " "
+ m_url + " " + m_version + "\r\n\r\n";
Looks like you assume no spaces in these fields, since they are space delimited
in Serialize/Deserialize, but you don't enforce that in the Setters. This will
almost surely make trouble for somebody down the line.  Perhaps %-encode in the
setters?

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.cc:286: } while (c != 0);
This is calculating the size, up to a NULL. Instead of scanning, how about
serializing the size as a leading uint32_t? Much faster.

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.cc:362: return GetSerializedSize ();
Wrong.  You need to return the *actual* number of bytes read, not how many you
*should have* read. The actual number is just len + 1.

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header.h
File src/internet/model/http-header.h (right):

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.h:167: bool   m_request;
Please document member variables.

https://codereview.appspot.com/13486044/diff/1/src/internet/model/http-header...
src/internet/model/http-header.h:202: std::map<std::string,
std::string>::iterator m_headerFieldMapIt;
Does this need to be a data member?  The code doesn't seem to use the prior
value of this, so couldn't it be a local in each function where you iterate or
find() over m_headerFieldMap?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b