forked from joygpwan/b409
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket_response_header.c
226 lines (157 loc) · 5.33 KB
/
bucket_response_header.c
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include "bucket_response_header.h"
#include "container.h"
#include "object_response_header.h"
/*
int get_bucket_header_yes(struct MHD_Response *response,struct sender_head send_header)
{
//
char *header_add;
struct stat buf;
char *temp;
temp=(char *)malloc(BUFLENGTH*sizeof(char));
//header_add=(char *)malloc(BUFLENGTH*sizeof(char));
header_add = MHD_get_response_header (response,"Date");
if (header_add != NULL)
{
if(Gen_Date(header_add)==0)
err_sys("get_object_header_yes Gen_Date error");
}
else
{
if(Gen_Date(header_add)==0)
err_sys("get_object_header_yes Gen_Date error");
if(MHD_add_response_header(response,"Date", header_add)==0)
{
//printf("%s\n",header_add);
err_sys("get_object_header_yes MHD_add_response_header Date error");
}
}
header_add = MHD_get_response_header (response,"Last-Modified");
if(stat(send_header.Pathname,&buf)<0)
err_sys("get_object_header_yes stat error");
else
{
if(Tran_Date(buf.st_mtime,temp)==0)
err_sys("get_object_header_yes Tran_Date error");
}
if (header_add != NULL)
{
strncpy(header_add,temp,strlen(temp)+1);
}
else
{
if(MHD_add_response_header(response,"Last-Modified", temp)==0)
err_sys("get_object_header_yes MHD_add_response_header Last-Modified error");
}
header_add = MHD_get_response_header (response,"Content-Length");
//ltoa(buf.st_size,temp,10);
temp=my_itoa(buf.st_size);
if (header_add != NULL)
{
//err_sys("get_object_header_yes Tran_Date error");
strncpy(header_add,temp,strlen(temp)+1);
}
else
{
if(MHD_add_response_header(response,"Content-Length", temp)==0)
err_sys("get_object_header_yes MHD_add_response_header Content-Length error");
}
header_add = MHD_get_response_header (response,"ETag");
if (header_add != NULL)
{
//header_add=NULL:
strncpy(header_add,"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"",strlen("\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"")+1);
}
else
{
if(MHD_add_response_header(response,"ETag", "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"")==0)
err_sys("get_object_header_yes MHD_add_response_header ETag error");
}
header_add = MHD_get_response_header (response,"Connection");
// ltoa(buf.st_size,temp,10);
if (header_add != NULL)
{
//err_sys("get_object_header_yes Tran_Date error");
strncpy(header_add,send_header.Connection,strlen(send_header.Connection)+1);
}
else
{
if(MHD_add_response_header(response,"Connection", send_header.Connection)==0)
err_sys("get_object_header_yes MHD_add_response_header Connection error");
}
header_add = MHD_get_response_header (response,"Content-Type");
//ltoa(buf.st_size,temp,10);
if (header_add != NULL)
{
//err_sys("get_object_header_yes Tran_Date error");
strncpy(header_add,"text/plain",strlen("text/plain")+1);
}
else
{
if(MHD_add_response_header(response,"Content-Length", "text/plain")==0)
err_sys("get_object_header_yes MHD_add_response_header Content-Length error");
}
header_add = MHD_get_response_header (response,"Server");
//ltoa(buf.st_size,temp,10);
if (header_add != NULL)
{
//err_sys("get_object_header_yes Tran_Date error");
strncpy(header_add,"Store B409",strlen("Store B409")+1);
}
else
{
if(MHD_add_response_header(response,"Server", "Store B409")==0)
err_sys("get_object_header_yes MHD_add_response_header Content-Length error");
}
return 1;
}
int get_bucket_header_no(struct MHD_Response *response,struct sender_head send_header)
{
//
char *header_add;
struct stat buf;
char *temp;
temp=(char *)malloc(BUFLENGTH*sizeof(char));
//header_add=(char *)malloc(BUFLENGTH*sizeof(char));
header_add = MHD_get_response_header (response,"Date");
if (header_add != NULL)
{
if(Gen_Date(header_add)==0)
err_sys("get_object_header_no Gen_Date error");
}
else
{
if(Gen_Date(header_add)==0)
err_sys("get_object_header_no Gen_Date error");
if(MHD_add_response_header(response,"Date", header_add)==0)
err_sys("get_object_header_no MHD_add_response_header Date error");
}
header_add = MHD_get_response_header (response,"Connection");
// ltoa(buf.st_size,temp,10);
if (header_add != NULL)
{
//err_sys("get_object_header_yes Tran_Date error");
strncpy(header_add,send_header.Connection,strlen(send_header.Connection)+1);
}
else
{
if(MHD_add_response_header(response,"Connection", send_header.Connection)==0)
err_sys("get_object_header_no MHD_add_response_header Connection error");
}
if(MHD_add_response_header(response,"Server", "Store B409")==0)
err_sys("get_object_header_no MHD_add_response_header Content-Length error");
header_add = MHD_get_response_header (response,"Server");
//ltoa(buf.st_size,temp,10);
if (header_add != NULL)
{
//err_sys("get_object_header_no Tran_Date error");
strncpy(header_add,"Store B409",strlen("Store B409")+1);
}
else
{
if(MHD_add_response_header(response,"x-amz-delete-marker", "TRUE")==0)
err_sys("get_object_header_no MHD_add_response_header x-amz-delete-marker error");
}
return 1;
}
*/