1 /*
2 * Copyright 2010-2013 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Christophe Huriaux, c.huriaux@gmail.com
7 * Adrien Destugues, pulkomandy@pulkomandy.tk
8 */
9
10 #include <UrlProtocolRoster.h>
11
12 #include <new>
13
14 #include <DataRequest.h>
15 #include <Debug.h>
16 #include <FileRequest.h>
17 #include <GopherRequest.h>
18 #include <HttpRequest.h>
19 #include <UrlRequest.h>
20
21 using namespace BPrivate::Network;
22
23
24 /* static */ BUrlRequest*
MakeRequest(const BUrl & url,BDataIO * output,BUrlProtocolListener * listener,BUrlContext * context)25 BUrlProtocolRoster::MakeRequest(const BUrl& url, BDataIO* output,
26 BUrlProtocolListener* listener, BUrlContext* context)
27 {
28 // TODO: instanciate the correct BUrlProtocol using add-on interface
29 if (url.Protocol() == "http") {
30 return new(std::nothrow) BHttpRequest(url, output, false, "HTTP",
31 listener, context);
32 } else if (url.Protocol() == "https") {
33 return new(std::nothrow) BHttpRequest(url, output, true, "HTTPS",
34 listener, context);
35 } else if (url.Protocol() == "file") {
36 return new(std::nothrow) BFileRequest(url, output, listener, context);
37 } else if (url.Protocol() == "data") {
38 return new(std::nothrow) BDataRequest(url, output, listener, context);
39 } else if (url.Protocol() == "gopher") {
40 return new(std::nothrow) BGopherRequest(url, output, listener, context);
41 }
42
43 return NULL;
44 }
45