Objectively
Ultra-lightweight object oriented framework for GNU C.
Loading...
Searching...
No Matches
URLResponse Struct Reference

#include <URLResponse.h>

Overview

A protocol-agnostic abstraction for URLSessionTask responses.

Definition at line 42 of file URLResponse.h.

Inheritance diagram for URLResponse:
Object

Properties

DictionaryhttpHeaders
 The HTTP response headers.
 
int httpStatusCode
 The HTTP response status code.
 
Object object
 The superclass.
 
- Properties inherited from Object
Classclazz
 Every instance of Object begins with a pointer to its Class.
 
unsigned int magic
 A header to allow introspection of Object types.
 

Methods

Class_URLResponse (void)
 The URLResponse archetype.
 
URLResponseinit (URLResponse *self)
 Initializes this URLResponse.
 
void setValueForHTTPHeaderField (URLREquest *self, const char *value, const char *field)
 
void setValueForHTTPHeaderField (URLResponse *self, const char *value, const char *field)
 Sets a value for the specified HTTP header.
 
- Methods inherited from Object
Class_Object (void)
 The Object archetype.
 
Objectcopy (const Object *self)
 Creates a shallow copy of this Object.
 
void dealloc (Object *self)
 Frees all resources held by this Object.
 
Stringdescription (const Object *self)
 
int hash (const Object *self)
 
Objectinit (Object *self)
 Initializes this Object.
 
bool isEqual (const Object *self, const Object *other)
 Tests equality of the other Object.
 
bool isKindOfClass (const Object *self, const Class *clazz)
 Tests for Class hierarchy membership.
 

Protected Attributes

URLResponseInterface * interface
 The interface.
 
- Protected Attributes inherited from Object
ObjectInterface * interface
 The interface.
 

Property Details

◆ httpHeaders

Dictionary* URLResponse::httpHeaders

The HTTP response headers.

Definition at line 58 of file URLResponse.h.

◆ httpStatusCode

int URLResponse::httpStatusCode

The HTTP response status code.

Definition at line 63 of file URLResponse.h.

◆ interface

URLResponseInterface* URLResponse::interface
protected

The interface.

Definition at line 53 of file URLResponse.h.

◆ object

Object URLResponse::object

The superclass.

Definition at line 47 of file URLResponse.h.

Method Details

◆ _URLResponse()

Class * _URLResponse ( void  )

The URLResponse archetype.

Returns
The URLResponse Class.

Definition at line 111 of file URLResponse.c.

111 {
112 static Class *clazz;
113 static Once once;
114
115 do_once(&once, {
116 clazz = _initialize(&(const ClassDef) {
117 .name = "URLResponse",
118 .superclass = _Object(),
119 .instanceSize = sizeof(URLResponse),
120 .interfaceOffset = offsetof(URLResponse, interface),
121 .interfaceSize = sizeof(URLResponseInterface),
123 });
124 });
125
126 return clazz;
127}
static void initialize(Class *clazz)
Definition Array.c:710
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition Class.c:86
long Once
The Once type.
Definition Once.h:37
#define do_once(once, block)
Executes the given block at most one time.
Definition Once.h:43
ClassDefs are passed to _initialize via an archetype to initialize a Class.
Definition Class.h:41
The runtime representation of a Class.
Definition Class.h:95
Class * clazz
Every instance of Object begins with a pointer to its Class.
Definition Object.h:55
Class * _Object(void)
The Object archetype.
Definition Object.c:136
A protocol-agnostic abstraction for URLSessionTask responses.
Definition URLResponse.h:42
URLResponseInterface * interface
The interface.
Definition URLResponse.h:53

◆ init()

URLResponse * init ( URLResponse self)

Initializes this URLResponse.

Parameters
selfThe URLResponse.
Returns
The initialized URLResponse, or NULL on error.

Definition at line 70 of file URLResponse.c.

70 {
71 return (URLResponse *) super(Object, self, init);
72}
#define super(type, obj, method,...)
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46
URLResponse * init(URLResponse *self)
Initializes this URLResponse.
Definition URLResponse.c:70

◆ setValueForHTTPHeaderField() [1/2]

void setValueForHTTPHeaderField ( URLREquest *  self,
const char *  value,
const char *  field 
)

◆ setValueForHTTPHeaderField() [2/2]

void setValueForHTTPHeaderField ( URLResponse self,
const char *  value,
const char *  field 
)

Sets a value for the specified HTTP header.

Parameters
selfThe URLRequest.
valueThe HTTP header value.
fieldThe HTTP header field.

Definition at line 78 of file URLResponse.c.

78 {
79
80 if (self->httpHeaders == NULL) {
82 }
83
84 String *object = str(value);
85 String *key = str(field);
86
87 $((Dictionary *) self->httpHeaders, setObjectForKey, object, key);
88
89 release(object);
90 release(key);
91}
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Definition Class.c:195
#define alloc(type)
Allocate and initialize and instance of type.
Definition Class.h:176
static void setObjectForKey(Dictionary *self, const ident obj, const ident key)
Definition Dictionary.c:634
String * str(const char *fmt,...)
Definition String.c:1084
Key-value stores.
Definition Dictionary.h:60
UTF-8 strings.
Definition String.h:69
Dictionary * httpHeaders
The HTTP response headers.
Definition URLResponse.h:58

The documentation for this struct was generated from the following files: