-
-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewritten http package for RFC 0033 #1563
Conversation
@pdtwonotes this needs to be rebased against master. Do you know how to do that? If not, ping me on IRC and I can help. |
@pdtwonotes there's a lot of non-standard formatting. i commented on a decent chunk of it and eventually stopped because my browser was having a hard time. i think enough should be covered to hit pretty much all the points. i'll take a look later on after that is cleaned up for other issues. two things i noticed, one of which i commented on.
I'm really excited about replacing the old http server. Thank you for taking this on. |
Where do I find these comments? And I thought I did rebase it! |
examples/httpget/httpget.pony
Outdated
// The positional parameter is the URL to be fetched. | ||
let urlref = try env.args( env.args.size() - 1 ) else "" end | ||
let url = try URL.valid(urlref) | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard library formatting would be for this else and other blocks to be on the same indentation level as the let
examples/httpget/httpget.pony
Outdated
end | ||
|
||
// The positional parameter is the URL to be fetched. | ||
let urlref = try env.args( env.args.size() - 1 ) else "" end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard library formatting would be to not have the spaces here.
(env.args.size() - 1)
examples/httpget/httpget.pony
Outdated
" --user (-u) Username for authenticated queries\n" + | ||
" --pass (-p) Password for authenticated queries\n" + | ||
" --output (-o) Name of file to write response body\n" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard library formatting would be for the )
to be at the end of line 56.
examples/httpget/httpget.pony
Outdated
let _env: Env | ||
|
||
new create( env: Env, url: URL, user: String, pass: String, | ||
output: String ) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard library formatting would be for the =>
to be on the next line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see this happening very often. What is the rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new create( env: Env, url: URL, user: String, pass: String,
output: String )
=>
when wrapping but this line is actually less than 80 characters and should be
new create(env: Env, url: URL, user: String, pass: String, output: String ) =>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeanTAllen you forgot to remove the space before the )
in your example - just to let @pdtwonotes know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jemc i did. man this PR, it makes my browser so slow when I'm on the review page and I type something and there is a second delay before anything shows up. I'm surprised there aren't more I Fubar'd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote nearly every file in the package, so it is big.
examples/httpget/httpget.pony
Outdated
// The Notify Factory will create HTTPHandlers as required. It is | ||
// done this way because we do not know exactly when an HTTPSession | ||
// is created - they can be re-used. | ||
let dumpMaker = recover val NotifyFactory.create( this ) end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create(this)
packages/net/http/server.pony
Outdated
""" | ||
_listen.dispose() | ||
for conn in _sessions.values() do | ||
conn.dispose() | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
packages/net/http/server.pony
Outdated
for new connections. Existing connections continue to use the old routes. | ||
Runs an HTTP server. | ||
|
||
### Server operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting is off for this section. actor/class comments get indented
packages/net/http/http_notify.pony
Outdated
an actor to deal with subsequent information pertaining to this | ||
message. | ||
""" | ||
fun ref chunk( data: ByteSeq val ) => None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be newlines between each function
packages/net/http/http_notify.pony
Outdated
essential fields filled in at this point, because ownership is being | ||
transferred to the session actor. This begins an outbound message. | ||
""" | ||
be finish() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be newline between each method
packages/net/http/discard_log.pony
Outdated
@@ -2,5 +2,6 @@ primitive DiscardLog | |||
""" | |||
Doesn't log anything. | |||
""" | |||
fun val apply(ip: String, request: Payload val, response: Payload val) => | |||
fun val apply(ip: String, transferred: USize, | |||
request: Payload val, response: Payload val) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
@pwdnotes sorry i forgot to hit submit for the comments. |
apparently only 1 file is in conflict as you can see below. |
packages/net/http/mimetypes.pony
Outdated
""" | ||
try | ||
// This will fail if no period is found. | ||
let dotpos = (name.rfind( ".", -1, 0 )+1).usize() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard library formatting would have no spaces between the arguments and the parentheses. Spaces should also be added around the addition so that it looks like (name.rfind(".", -1, 0) + 1).usize()
packages/net/http/payload.pony
Outdated
let _headers: Map[String, String] = _headers.create() | ||
let _body: Array[ByteSeq] = _body.create() | ||
var _body: Array[ByteSeq val] = _body.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var field is never reassigned and is only initialized with a constructor, so it should be declared with embed.
packages/net/http/payload.pony
Outdated
let h = handler as ResponseHandler | ||
h(consume this, Payload.response(StatusInternalServerError)) | ||
end | ||
None /* try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation of None
packages/net/http/payload.pony
Outdated
""" | ||
Write the response-specific parts of an HTTP message. | ||
""" | ||
conn.write(proto + " " + status.string() + " " + method + "\r\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String concatenation using +
here can be slow since it allocates a new string on every +
I think the failing test is actually in error. The old version of URL.decode would decode "+" as itself, whereas in a URL "+" should decode as space. I fixed that, and that is what is breaking test test. |
Note #1543 for a version bump / release. |
This is my rewrite of the
net/http
package, as described in RFC 33. It also includesexamples/httpget
andexamples/httpserver
. The server example is quite limited and just shows that it works. A much more elaborate example can be found at pdtwonotes/tokara in thehttpng
branch.