Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_url_safe.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
40
41#ifndef N_URL_SAFE_H
42#define N_URL_SAFE_H
43
44#include <stddef.h>
45#include <stdint.h>
46
48#define N_URL_SAFE_HOST_MAX 253u
50#define N_URL_SAFE_MAX 1024u
52#define N_URL_SAFE_MIME_MAX 127u
54#define N_URL_SAFE_HEAD_MAX 16384u
55
59typedef struct {
60 int https;
61 uint16_t port;
65
75
88int n_url_safe_parse(const char* url, size_t len, n_url_safe* out);
89
103int n_url_safe_head_parse(const char* buf, size_t len, n_url_safe_head* out);
104
119int n_url_safe_resolve(const char* base, size_t base_len, const char* loc, size_t loc_len, char* out, size_t cap);
120
134int n_url_safe_find(const char* text, size_t len, char* out, size_t cap);
135
136#endif /* N_URL_SAFE_H */
char host[253u+1]
Definition n_url_safe.h:62
#define N_URL_SAFE_MIME_MAX
Longest captured Content-Type (mime), parameters dropped.
Definition n_url_safe.h:52
int n_url_safe_resolve(const char *base, size_t base_len, const char *loc, size_t loc_len, char *out, size_t cap)
resolve a redirect Location against a request URL
Definition n_url_safe.c:308
uint16_t port
Definition n_url_safe.h:61
char location[1024u+1]
Location (redirects).
Definition n_url_safe.h:72
int n_url_safe_find(const char *text, size_t len, char *out, size_t cap)
find the first http(s) URL in a block of text
Definition n_url_safe.c:344
long long content_length
Content-Length, or -1 if absent.
Definition n_url_safe.h:69
size_t head_len
bytes through the terminating CRLFCRLF
Definition n_url_safe.h:71
int chunked
Transfer-Encoding: chunked present.
Definition n_url_safe.h:70
#define N_URL_SAFE_MAX
Longest URL / path / Location accepted.
Definition n_url_safe.h:50
int status
HTTP status code, e.g.
Definition n_url_safe.h:68
char content_type[127u+1]
mime, params dropped
Definition n_url_safe.h:73
int n_url_safe_head_parse(const char *buf, size_t len, n_url_safe_head *out)
parse an HTTP/1.x response head from [buf, buf+len)
Definition n_url_safe.c:230
int https
1 = https (default port 443), 0 = http (80)
Definition n_url_safe.h:60
#define N_URL_SAFE_HOST_MAX
Longest hostname / IP literal accepted (RFC 1035 limit).
Definition n_url_safe.h:48
char path[1024u+1]
Definition n_url_safe.h:63
int n_url_safe_parse(const char *url, size_t len, n_url_safe *out)
parse an absolute http(s) URL [url, url+len) into a bounded struct
Definition n_url_safe.c:76
The parts of an absolute http(s) URL.
Definition n_url_safe.h:59
The response-head fields a fetcher acts on.
Definition n_url_safe.h:67