Skip to content
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

'index out of bounds' in httpserver.nim #8

Closed
jameshfisher opened this issue Jan 9, 2011 · 2 comments
Closed

'index out of bounds' in httpserver.nim #8

jameshfisher opened this issue Jan 9, 2011 · 2 comments

Comments

@jameshfisher
Copy link

When running the example at http://force7.de/nimrod/httpserver.html , and accessing localhost from Chromium (specifically), I get an

Error: unhandled exception: index out of bounds [EInvalidIndex]

at the line in httpserver.nim in next() that reads

if cmpIgnoreCase(data[0], "GET") == 0 or cmpIgnoreCase(data[0], "POST") == 0:

This is due to data having no elements, due to buf being the null string. It seems that, rather than sending a request with "GET / HTTP/1.1" as the first line, Chromium is sending a zero-length line. I don't know if this is proper behaviour, but in any case my program should not crash. So I propose changing this to something like

if data.len() == 0 or cmpIgnoreCase(data[0], "GET") == 0 or cmpIgnoreCase(data[0], "POST") == 0:
@Araq
Copy link
Member

Araq commented Jan 13, 2011

I changed the code to not use split() at all which should be more efficient anyway. However, httpclient does not work on my Windows VM at all, so I couldn't test it properly on Windows.

@Araq
Copy link
Member

Araq commented Feb 4, 2011

No feedback from reporter and EInvalidIndex fixed.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants