Artifact 8afa2d2f59c393ffc5225fdd3fddfe5bf9ca9be3adbe1f2139e84dec47e82a4b:
- File
src/OFURLHandler_HTTP.m
— part of check-in
[5613565c63]
at
2018-02-25 16:06:14
on branch trunk
— OFURLHandler: Add a handler for HTTP(S)
This makes -[initWithContentsOfURL:] work again for HTTP(S) URLs. (user: js, size: 1152) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFURLHandler_HTTP.h" #import "OFHTTPClient.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" @implementation OFURLHandler_HTTP - (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFHTTPClient *client = [OFHTTPClient client]; OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL]; OFHTTPResponse *response = [client performRequest: request]; [response retain]; objc_autoreleasePoolPop(pool); return [response autorelease]; } @end