-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreply.cx
More file actions
executable file
·72 lines (72 loc) · 2.38 KB
/
Copy pathreply.cx
File metadata and controls
executable file
·72 lines (72 loc) · 2.38 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//-*-C-*-
/*******************************************************************************
* ___ workplace
* ¦OUX¦ C+
* ¦/C+¦ server
* --- web server
* ‘HTTP’ replies
* ©overcq on ‟Gentoo Linux 17.1” “x86_64” 2020‒4‒13 M
*******************************************************************************/
struct E_reply_Z_status_msg
{ N code;
Pc s;
}E_reply_S_status_msg[] =
{ { 200, "OK" }
, { 301, "Moved Permanently" }
, { 302, "Found" }
, { 400, "Bad Request" }
, { 403, "Forbidden" }
, { 404, "Not Found" }
, { 500, "Internal Server Error" }
};
N E_reply_S_status_msg_n = sizeof( E_reply_S_status_msg ) / sizeof( E_reply_S_status_msg[0] );
//==============================================================================
N
E_reply_I_code_( SSL *ssl
, int fd
, N code
, B end
, B close
, B http_11
){ for_n( i, E_reply_S_status_msg_n )
if( E_reply_S_status_msg[i].code == code )
{ N l = 9 + 4 + E_text_Z_s0_R_l( E_reply_S_status_msg[i].s ) + 2;
if( http_11 && close)
l += E_text_Z_s0_R_l( "Connection: close\r\n" );
if(end)
l += 2;
Pc s = M(l);
if( !s )
return ~0;
Pc s_1 = E_text_Z_s_P_copy_s0( s, "HTTP/1." );
if( http_11 )
E_text_Z_s_P_copy_s0( s_1, "1 " );
else
E_text_Z_s_P_copy_s0( s_1, "0 " );
E_text_Z_n_N_s( s + 9 + 3, E_reply_S_status_msg[i].code, 10 );
*( s + 9 + 3 ) = ' ';
s_1 = E_text_Z_s_P_copy_s0( E_text_Z_s_P_copy_s0( s + 9 + 4, E_reply_S_status_msg[i].s ), "\r\n" );
if( http_11 && close )
s_1 = E_text_Z_s_P_copy_s0( s_1, "Connection: close\r\n" );
if(end)
E_text_Z_s_P_copy_s0( s_1, "\r\n" );
G_(); Gsl( s, 9 + 4 + E_text_Z_s0_R_l( E_reply_S_status_msg[i].s ));
if( E_net_cli_I_write_data( ssl, fd, s, l ) != l )
{ N r = W(s);
return r ? r : ~0;
}
N r = W(s);
return r ? r : 0;
}
E_reply_I_code_( ssl, fd, 500, end, close, http_11 );
return ~0;
}
N
E_reply_I_code( SSL *ssl
, int fd
, N code
, B close
, B http_11
){ return E_reply_I_code_( ssl, fd, code, yes, close, http_11 );
}
/******************************************************************************/