Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
Properties | Methods | Protected Attributes
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. More...
 
int httpStatusCode
 The HTTP response status code. More...
 
Object object
 The superclass. More...
 
- Properties inherited from Object
Classclazz
 Every instance of Object begins with a pointer to its Class. More...
 

Methods

Class_URLResponse (void)
 The URLResponse archetype. More...
 
URLResponseinit (URLResponse *self)
 Initializes this URLResponse. More...
 
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. More...
 
- Methods inherited from Object
Class_Object (void)
 The Object archetype. More...
 
Objectcopy (const Object *self)
 Creates a shallow copy of this Object. More...
 
void dealloc (Object *self)
 Frees all resources held by this Object. More...
 
Stringdescription (const Object *self)
 
int hash (const Object *self)
 
Objectinit (Object *self)
 Initializes this Object. More...
 
_Bool isEqual (const Object *self, const Object *other)
 Tests equality of the other Object. More...
 
_Bool isKindOfClass (const Object *self, const Class *clazz)
 Tests for Class hierarchy membership. More...
 

Protected Attributes

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

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}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition: Class.c:91
static void initialize(Class *clazz)
Definition: URLResponse.c:98
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:51
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 $((MutableDictionary *) 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:196
#define alloc(type)
Allocate and initialize and instance of type.
Definition: Class.h:159
static void setObjectForKey(MutableDictionary *self, const ident obj, const ident key)
String * str(const char *fmt,...)
Definition: String.c:739
Immutable key-value stores.
Definition: Dictionary.h:60
Mutable key-value stores.
Immutable 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: