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 #ifndef LIBNETAPI_DEPRECATED 22 using namespace BPrivate::Network; 23 #endif 24 25 /* static */ BUrlRequest* 26 BUrlProtocolRoster::MakeRequest(const BUrl& url, 27 BUrlProtocolListener* listener, BUrlContext* context) 28 { 29 // TODO: instanciate the correct BUrlProtocol using add-on interface 30 if (url.Protocol() == "http") { 31 return new(std::nothrow) BHttpRequest(url, false, "HTTP", listener, 32 context); 33 } else if (url.Protocol() == "https") { 34 return new(std::nothrow) BHttpRequest(url, true, "HTTPS", listener, 35 context); 36 } else if (url.Protocol() == "file") { 37 return new(std::nothrow) BFileRequest(url, listener, context); 38 } else if (url.Protocol() == "data") { 39 return new(std::nothrow) BDataRequest(url, listener, context); 40 } else if (url.Protocol() == "gopher") { 41 return new(std::nothrow) BGopherRequest(url, listener, context); 42 } 43 44 return NULL; 45 } 46