Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
Properties | Methods | Protected Attributes
URLRequest Struct Reference

#include <URLRequest.h>

Overview

A protocol-agnostic abstraction for requesting resources via URLs.

Definition at line 56 of file URLRequest.h.

Inheritance diagram for URLRequest:
Object

Properties

DatahttpBody
 The HTTP request body, sent as POST or PUT data. More...
 
DictionaryhttpHeaders
 The HTTP request headers. More...
 
HTTPMethod httpMethod
 The HTTP request method. More...
 
Object object
 The superclass. More...
 
URLurl
 The URL. More...
 
- Properties inherited from Object
Classclazz
 Every instance of Object begins with a pointer to its Class. More...
 

Methods

Class_URLRequest (void)
 The URLRequest archetype. More...
 
URLRequestinitWithURL (URLRequest *self, URL *url)
 Initializes this URLRequest with the specified URL. More...
 
void setValueForHTTPHeaderField (URLREquest *self, const char *value, const char *field)
 
void setValueForHTTPHeaderField (URLRequest *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

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

Property Details

◆ httpBody

Data* URLRequest::httpBody

The HTTP request body, sent as POST or PUT data.

Definition at line 72 of file URLRequest.h.

◆ httpHeaders

Dictionary* URLRequest::httpHeaders

The HTTP request headers.

Definition at line 77 of file URLRequest.h.

◆ httpMethod

HTTPMethod URLRequest::httpMethod

The HTTP request method.

Definition at line 82 of file URLRequest.h.

◆ interface

URLRequestInterface* URLRequest::interface
protected

The interface.

Definition at line 67 of file URLRequest.h.

◆ object

Object URLRequest::object

The superclass.

Definition at line 61 of file URLRequest.h.

◆ url

URL* URLRequest::url

The URL.

Definition at line 87 of file URLRequest.h.

Method Details

◆ _URLRequest()

Class * _URLRequest ( void  )

The URLRequest archetype.

Returns
The URLRequest Class.

Definition at line 122 of file URLRequest.c.

122 {
123 static Class *clazz;
124 static Once once;
125
126 do_once(&once, {
127 clazz = _initialize(&(const ClassDef) {
128 .name = "URLRequest",
129 .superclass = _Object(),
130 .instanceSize = sizeof(URLRequest),
131 .interfaceOffset = offsetof(URLRequest, interface),
132 .interfaceSize = sizeof(URLRequestInterface),
134 });
135 });
136
137 return clazz;
138}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition: Class.c:91
static void initialize(Class *clazz)
Definition: URLRequest.c:109
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 requesting resources via URLs.
Definition: URLRequest.h:56
URLRequestInterface * interface
The interface.
Definition: URLRequest.h:67

◆ initWithURL()

URLRequest * initWithURL ( URLRequest self,
URL url 
)

Initializes this URLRequest with the specified URL.

Parameters
selfThe URLRequest.
urlThe URL.
Returns
The initialized URLRequest, or NULL on error.

Definition at line 73 of file URLRequest.c.

73 {
74
75 assert(url);
76
77 self = (URLRequest *) super(Object, self, init);
78 if (self) {
79 self->url = retain(url);
80 }
81
82 return self;
83}
ident retain(ident obj)
Atomically increment the given Object's reference count.
Definition: Class.c:211
#define super(type, obj, method,...)
Object is the root Class of The Objectively Class hierarchy.
Definition: Object.h:46
Object * init(Object *self)
Initializes this Object.
Definition: Object.c:83
URL * url
The URL.
Definition: URLRequest.h:87

◆ setValueForHTTPHeaderField() [1/2]

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

◆ setValueForHTTPHeaderField() [2/2]

void setValueForHTTPHeaderField ( URLRequest 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 89 of file URLRequest.c.

89 {
90
91 if (self->httpHeaders == NULL) {
93 }
94
95 String *object = str(value);
96 String *key = str(field);
97
98 $((MutableDictionary *) self->httpHeaders, setObjectForKey, object, key);
99
100 release(object);
101 release(key);
102}
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 request headers.
Definition: URLRequest.h:77

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