Overview
Comment: | OFURLHandler: Add a handler for HTTP(S)
This makes -[initWithContentsOfURL:] work again for HTTP(S) URLs. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5613565c631b5b7f6e84aee288e0de66 |
User & Date: | js on 2018-02-25 16:06:14 |
Other Links: | manifest | tags |
Context
2018-02-25
| ||
17:16 | No self = [self init…] with self-releasing @catch check-in: 81156ee75a user: js tags: trunk | |
16:06 | OFURLHandler: Add a handler for HTTP(S) check-in: 5613565c63 user: js tags: trunk | |
15:48 | OFHTTPClient: Reintroduce -[performRequest:] check-in: f80b0d270c user: js tags: trunk | |
Changes
Modified src/Makefile from [1e0fce5f8d] to [ba996d2e9a].
︙ | ︙ | |||
184 185 186 187 188 189 190 | SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ | | > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ OFTCPSocket+SOCKS5.m \ OFURLHandler_HTTP.m OBJS_EXTRA = ${RUNTIME_RUNTIME_A} \ ${EXCEPTIONS_EXCEPTIONS_A} \ ${ENCODINGS_ENCODINGS_A} \ ${FORWARDING_FORWARDING_A} \ ${INVOCATION_INVOCATION_A} LIB_OBJS_EXTRA = ${RUNTIME_RUNTIME_LIB_A} \ |
︙ | ︙ |
Modified src/OFURLHandler.m from [f82740d977] to [e4e7822d0d].
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #ifdef OF_HAVE_FILES # import "OFURLHandler_file.h" #endif static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; #endif @implementation OFURLHandler | > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #ifdef OF_HAVE_FILES # import "OFURLHandler_file.h" #endif #ifdef OF_HAVE_SOCKETS # import "OFURLHandler_HTTP.h" #endif static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; #endif @implementation OFURLHandler |
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | mutex = [[OFMutex alloc] init]; #endif #ifdef OF_HAVE_FILES [self registerClass: [OFURLHandler_file class] forScheme: @"file"]; #endif } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; | > > > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | mutex = [[OFMutex alloc] init]; #endif #ifdef OF_HAVE_FILES [self registerClass: [OFURLHandler_file class] forScheme: @"file"]; #endif #ifdef OF_HAVE_SOCKETS [self registerClass: [OFURLHandler_HTTP class] forScheme: @"http"]; [self registerClass: [OFURLHandler_HTTP class] forScheme: @"https"]; #endif } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; |
︙ | ︙ |
Added src/OFURLHandler_HTTP.h version [abd403bde8].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* * 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. */ #import "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFURLHandler_HTTP: OFURLHandler @end OF_ASSUME_NONNULL_END |
Added src/OFURLHandler_HTTP.m version [8afa2d2f59].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * 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 |