http_listener.support doesn't support to call my handle for respond to request

Jul 2, 2015 at 8:50 AM
http_listener.support doesn't support to call my handle for respond to request

////////////////////////////////////////////////////////////////////////////////////////
void HandleGet(http_request request)
{
request.reply(status_codes::OK, U("Hello REST"));
}
main(){
http_listener listener(L"http://localhost:20001");
listener.open();
listener.support(methods::GET, HandleGet);
while (true);
}
////////////////////////////////////////////////////////////////////////////////////////

not only that code doesn't work as I want, even I tried about 3 sample codes online.
Because listener opens, client got respond for request. But, status_code is 400(Bad Request).
I set break point in HandleGet function but the process doesn't passby although I sent GET REQUEST.
So, now I'm not sure the function "support" works well............
or any problem in my code?? please check it...

sample codes I tried:
http://mariusbancila.ro/blog/2013/08/19/full-fledged-client-server-example-with-cpprest-sdk-110/
https://casablanca.codeplex.com/wikipage?title=HTTP%20Listener&referringTitle=Documentation

I use Window7, VS2013, cpprestsdk 2.6.0 with NuGet........
please help me.
Coordinator
Jul 2, 2015 at 9:59 PM
Hi hyunjuneshin,

Are you trying to make requests to your listener off of or from a different machine? For the http_listener on Windows, we build directly on top of the Windows HTTP Server API. So for listening to external requests you will have to follow the same rules. Specifically you need administrative privileges when running or have to have an admin make a reservation on a portion of the desired URI. See the HTTP Server API for more documentation.

Steve
Jul 3, 2015 at 12:33 AM
Thanks for quick reply

Are you trying to make requests to your listener off of or from a different machine?
->I have an REST client and I'm testing with DHC application in Google web stroe(https://chrome.google.com/webstore/search/dhc?hl=ko).
->And I'm operating client(DHC) and server(I made with cpprestsdk) in same computer.__

For the http_listener on Windows, we build directly on top of the Windows HTTP Server API.
So for listening to external requests you will have to follow the same rules.
->What's the rule?

Specifically you need administrative privileges when running or have to have an admin make a reservation on a portion of the desired URI.
->When I test it locally, do I need to have privileges?
->When I test it from other machine, how can I get privileges?

See the HTTP Server API for more documentation.
->documentation on your website?(https://casablanca.codeplex.com/documentation)
there is not enough information. HTTP Listener documentation has only the sample that I already tried and fail. Reference Documentation has no detail about functions that I need to use. :(

I'm really sorry to bother you.......... I really should develope a REST server and I'm trying to know how to. But it's not easy for me. plz answer me.... thanks.
Coordinator
Jul 6, 2015 at 5:28 PM
Hi hyunjuneshin,

If you need to handle requests coming from off the machine you need to run the program with administrative privileges on Windows. Can you please try that and see if everything works. Another option is to have the system administrator register and reserve the URL, more information can be found here in the documentation for the Windows HTTP Server API.

Steve