X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;ds=sidebyside;f=src%2Ffilter_http_file.cpp;h=18bdd571f83e27a1b0ccf0702807dff09b8de866;hb=08044cc9a9980c950c294d0193c337b4ba0ba732;hp=1038eabd2499e402de1554ec3c4041e4e02cc7a0;hpb=f383972cb68f4bd0ae13101600281313d1fa9665;p=metaproxy-moved-to-github.git diff --git a/src/filter_http_file.cpp b/src/filter_http_file.cpp index 1038eab..18bdd57 100644 --- a/src/filter_http_file.cpp +++ b/src/filter_http_file.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2013 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -138,6 +138,13 @@ void yf::HttpFile::Rep::fetch_file(mp::Session &session, { mp::odr o(ODR_ENCODE); + if (strcmp(req->method, "GET")) + { + Z_GDU *gdu = o.create_HTTP_Response(session, req, 405); + package.response() = gdu; + return; + } + FILE *f = fopen(fname.c_str(), "rb"); if (!f) { @@ -175,16 +182,14 @@ void yf::HttpFile::Rep::fetch_file(mp::Session &session, fclose(f); Z_GDU *gdu = 0; + mp::odr decode(ODR_DECODE); if (raw) { - odr_setbuf(o, (char *) fbuf, sz, 0); - int r = z_GDU(o, &gdu, 0, 0); + odr_setbuf(decode, (char *) fbuf, sz, 0); + int r = z_GDU(decode, &gdu, 0, 0); if (!r) { - Z_GDU *gdu = o.create_HTTP_Response(session, req, 500); - package.response() = gdu; - fclose(f); - return; + gdu = o.create_HTTP_Response(session, req, 500); } } else