From: martin-s Date: Thu, 23 Dec 2010 20:22:01 +0000 (+0000) Subject: Add:Core:More flexibility for http requests X-Git-Tag: navit-0.5.0.5194svn~1381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=417f4847b113c8bede059c8c0cab2406d7221eeb;p=profile%2Fivi%2Fnavit.git Add:Core:More flexibility for http requests git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3814 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index 5802565..211b8a0 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -331,6 +331,8 @@ ATTR(house_number_right_odd) ATTR(house_number_right_even) ATTR(map_release) ATTR(accesskey) +ATTR(http_method) +ATTR(http_header) ATTR2(0x0003ffff,type_string_end) ATTR2(0x00040000,type_special_begin) ATTR(order) diff --git a/navit/navit/file.c b/navit/navit/file.c index f5814e0..8bdf647 100644 --- a/navit/navit/file.c +++ b/navit/navit/file.c @@ -111,9 +111,9 @@ file_socket_connect(char *host, char *service) #endif static int -file_http_request(struct file *file, char *host, char *path) +file_http_request(struct file *file, char *method, char *host, char *path, char *header) { - char *request=g_strdup_printf("GET %s HTTP/1.0\r\nUser-Agent: navit %s\r\nHost: %s\r\n\r\n",path,version,host); + char *request=g_strdup_printf("%s %s HTTP/1.0\r\nUser-Agent: navit %s\r\nHost: %s%s%s%s\r\n\r\n",method,path,version,host,header?"\r\n":"",header?header:"",header?"\r\n":""); write(file->fd, request, strlen(request)); file->requests++; } @@ -154,13 +154,19 @@ file_create(char *name, struct attr **options) char *host=g_strdup(name+7); char *port=strchr(host,':'); char *path=strchr(name+7,'/'); + char *method="GET"; + char *header=NULL; + if ((attr=attr_search(options, NULL, attr_http_method)) && attr->u.str) + method=attr->u.str; + if ((attr=attr_search(options, NULL, attr_http_header)) && attr->u.str) + header=attr->u.str; if (path) host[path-name-7]='\0'; if (port) *port++='\0'; dbg(0,"host=%s path=%s\n",host,path); file->fd=file_socket_connect(host,port?port:"80"); - file_http_request(file,host,path); + file_http_request(file,method,host,path,header); file->special=1; g_free(host); }