comparison http.c @ 885:da1d5db0ce5c libavformat

COSMETICS: Remove all trailing whitespace.
author diego
date Sat, 17 Dec 2005 18:14:38 +0000
parents 095009fc2f35
children edbe5c3717f9
comparison
equal deleted inserted replaced
884:2ece9c9dd94c 885:da1d5db0ce5c
71 return -ENOMEM; 71 return -ENOMEM;
72 } 72 }
73 h->priv_data = s; 73 h->priv_data = s;
74 74
75 proxy_path = getenv("http_proxy"); 75 proxy_path = getenv("http_proxy");
76 use_proxy = (proxy_path != NULL) && !getenv("no_proxy") && 76 use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
77 strstart(proxy_path, "http://", NULL); 77 strstart(proxy_path, "http://", NULL);
78 78
79 /* fill the dest addr */ 79 /* fill the dest addr */
80 redo: 80 redo:
81 /* needed in any case to build the host string */ 81 /* needed in any case to build the host string */
82 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, 82 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
83 path1, sizeof(path1), uri); 83 path1, sizeof(path1), uri);
84 if (port > 0) { 84 if (port > 0) {
85 snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port); 85 snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
86 } else { 86 } else {
87 pstrcpy(hoststr, sizeof(hoststr), hostname); 87 pstrcpy(hoststr, sizeof(hoststr), hostname);
88 } 88 }
89 89
90 if (use_proxy) { 90 if (use_proxy) {
91 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, 91 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
92 NULL, 0, proxy_path); 92 NULL, 0, proxy_path);
93 path = uri; 93 path = uri;
94 } else { 94 } else {
95 if (path1[0] == '\0') 95 if (path1[0] == '\0')
96 path = "/"; 96 path = "/";
140 } 140 }
141 141
142 static int process_line(HTTPContext *s, char *line, int line_count) 142 static int process_line(HTTPContext *s, char *line, int line_count)
143 { 143 {
144 char *tag, *p; 144 char *tag, *p;
145 145
146 /* end of header */ 146 /* end of header */
147 if (line[0] == '\0') 147 if (line[0] == '\0')
148 return 0; 148 return 0;
149 149
150 p = line; 150 p = line;
158 printf("http_code=%d\n", s->http_code); 158 printf("http_code=%d\n", s->http_code);
159 #endif 159 #endif
160 } else { 160 } else {
161 while (*p != '\0' && *p != ':') 161 while (*p != '\0' && *p != ':')
162 p++; 162 p++;
163 if (*p != ':') 163 if (*p != ':')
164 return 1; 164 return 1;
165 165
166 *p = '\0'; 166 *p = '\0';
167 tag = line; 167 tag = line;
168 p++; 168 p++;
169 while (isspace(*p)) 169 while (isspace(*p))
170 p++; 170 p++;
196 post ? "POST" : "GET", 196 post ? "POST" : "GET",
197 path, 197 path,
198 LIBAVFORMAT_IDENT, 198 LIBAVFORMAT_IDENT,
199 hoststr, 199 hoststr,
200 b64_encode(auth)); 200 b64_encode(auth));
201 201
202 if (http_write(h, s->buffer, strlen(s->buffer)) < 0) 202 if (http_write(h, s->buffer, strlen(s->buffer)) < 0)
203 return AVERROR_IO; 203 return AVERROR_IO;
204 204
205 /* init input buffer */ 205 /* init input buffer */
206 s->buf_ptr = s->buffer; 206 s->buf_ptr = s->buffer;
207 s->buf_end = s->buffer; 207 s->buf_end = s->buffer;
208 s->line_count = 0; 208 s->line_count = 0;
209 s->location[0] = '\0'; 209 s->location[0] = '\0';
210 if (post) { 210 if (post) {
211 sleep(1); 211 sleep(1);
212 return 0; 212 return 0;
213 } 213 }
214 214
215 /* wait for header */ 215 /* wait for header */
216 q = line; 216 q = line;
217 for(;;) { 217 for(;;) {
218 ch = http_getc(s); 218 ch = http_getc(s);
219 if (ch < 0) 219 if (ch < 0)
284 }; 284 };
285 285
286 /***************************************************************************** 286 /*****************************************************************************
287 * b64_encode: stolen from VLC's http.c 287 * b64_encode: stolen from VLC's http.c
288 *****************************************************************************/ 288 *****************************************************************************/
289 289
290 static char *b64_encode( const unsigned char *src ) 290 static char *b64_encode( const unsigned char *src )
291 { 291 {
292 static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 292 static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
293 unsigned int len= strlen(src); 293 unsigned int len= strlen(src);
294 char *ret, *dst; 294 char *ret, *dst;
315 else 315 else
316 { 316 {
317 *dst++ = '='; 317 *dst++ = '=';
318 break; 318 break;
319 } 319 }
320 320
321 while( i_shift >= 6 ) 321 while( i_shift >= 6 )
322 { 322 {
323 i_shift -= 6; 323 i_shift -= 6;
324 *dst++ = b64[(i_bits >> i_shift)&0x3f]; 324 *dst++ = b64[(i_bits >> i_shift)&0x3f];
325 } 325 }
326 } 326 }
327 327
328 *dst++ = '\0'; 328 *dst++ = '\0';
329 329
330 return ret; 330 return ret;
331 } 331 }
332 332