Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
96fc434
)
Fixed stdredir to handle querystrings properly.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Sep 2010 00:58:14 +0000
(
02:58
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Sep 2010 00:58:14 +0000
(
02:58
+0200)
lib/resp.c
patch
|
blob
|
blame
|
history
diff --git
a/lib/resp.c
b/lib/resp.c
index
1b08b00
..
7de5c90
100644
(file)
--- a/
lib/resp.c
+++ b/
lib/resp.c
@@
-121,7
+121,7
@@
void simpleerror(int fd, int code, char *msg, char *fmt, ...)
void stdredir(struct hthead *req, int fd, int code, char *dst)
{
FILE *out;
void stdredir(struct hthead *req, int fd, int code, char *dst)
{
FILE *out;
- char *sp, *cp, *ep, *path, *url, *adst, *proto, *host;
+ char *sp, *cp, *ep, *
qs, *
path, *url, *adst, *proto, *host;
sp = strchr(dst, '/');
cp = strchr(dst, ':');
sp = strchr(dst, '/');
cp = strchr(dst, ':');
@@
-140,11
+140,14
@@
void stdredir(struct hthead *req, int fd, int code, char *dst)
} else {
if((*(url = req->url)) == '/')
url++;
} else {
if((*(url = req->url)) == '/')
url++;
- if((ep = strrchr(url, '/')) != NULL)
- ep++;
- else
- ep = url;
- path = sprintf2("%.*s%s", ep - url, url, dst);
+ if((ep = strchr(url, '?')) == NULL) {
+ ep = url + strlen(url);
+ qs = "";
+ } else {
+ qs = ep;
+ }
+ for(; (ep > url) && (ep[-1] != '/'); ep--);
+ path = sprintf2("%.*s%s%s", ep - url, url, dst, qs);
}
adst = sprintf2("%s://%s/%s", proto, host, path);
free(path);
}
adst = sprintf2("%s://%s/%s", proto, host, path);
free(path);