# never mind, I was being dense. It was the browser requesting favicon.ico. Too bad I can't close my own issue on Codeplex. :|
Using the following code, my console spits out the text two times per request when I visit localhost in the browser.
```c++
#include <iostream>
#include <cpprest\http_listener.h>
using namespace web::http;
using namespace web::http::experimental::listener;
int main()
{
auto runcount = 0;
auto uri = web::uri(L"http://localhost:55555");
auto listener = http_listener(uri);
listener.support(methods::GET, [&](http_request request){
runcount++;
std::cout << "Got Request!" << std::endl;
std::cout << "Ran handler " << runcount << " times." << std::endl;
request.reply(status_codes::OK, L"Hello World!");
});
try
{
listener.open();
while (true);
}
catch (const http_exception & e)
{
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
```
After visiting the url once, the console says:
```
Got Request!
Ran handler 1 times.
Got Request!
Ran handler 2 times.
```
After visting it one more time, the console says (in total):
```
Got Request!
Ran handler 1 times.
Got Request!
Ran handler 2 times.
Got Request!
Ran handler 3 times.
Got Request!
Ran handler 4 times.
```
I am new to C++ so I am hoping it is just a rookie error, but if it is not, here is your bug report! :)
Using the following code, my console spits out the text two times per request when I visit localhost in the browser.
```c++
#include <iostream>
#include <cpprest\http_listener.h>
using namespace web::http;
using namespace web::http::experimental::listener;
int main()
{
auto runcount = 0;
auto uri = web::uri(L"http://localhost:55555");
auto listener = http_listener(uri);
listener.support(methods::GET, [&](http_request request){
runcount++;
std::cout << "Got Request!" << std::endl;
std::cout << "Ran handler " << runcount << " times." << std::endl;
request.reply(status_codes::OK, L"Hello World!");
});
try
{
listener.open();
while (true);
}
catch (const http_exception & e)
{
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
```
After visiting the url once, the console says:
```
Got Request!
Ran handler 1 times.
Got Request!
Ran handler 2 times.
```
After visting it one more time, the console says (in total):
```
Got Request!
Ran handler 1 times.
Got Request!
Ran handler 2 times.
Got Request!
Ran handler 3 times.
Got Request!
Ran handler 4 times.
```
I am new to C++ so I am hoping it is just a rookie error, but if it is not, here is your bug report! :)