Re: Необходимо вернут текст на определенном location ...

Artem S. Povaluhin artem.povaluhin на gmail.com
Ср Сен 21 12:09:04 UTC 2011


Hello!


On 09/21/2011 03:12 PM, Maxim Dounin wrote:
> Hello!
>
> On Wed, Sep 21, 2011 at 01:19:13PM +0400, Eugene Batogov wrote:
>
>> Привет всем.
>> Может ли nginx вернуть строку на определенный location.
>> Я хочу сделать что-то наподобие этого:
>>
>>         location /portal/v1/search/
>> {
>>            return {"programs":[],"totalCount":0};
>>            error_page      404 502 504 = @fallback;
>>          }
> return 200 '{"programs":[],"totalCount":0}';
раз речь зашла, на днях обнаружил, что странно оно работает в ответ на POST.

conf:
         location /dummy {
             return 200 "DONE";
         }
curl:
drsm at t400:~$ curl localhost/dummy -v --data "OMG"
* About to connect() to localhost port 80 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
 > POST /dummy HTTP/1.1
 > User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 
OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
 > Host: localhost
 > Accept: */*
 > Content-Length: 3
 > Content-Type: application/x-www-form-urlencoded
 >
< HTTP/1.1 200 OK
< Server: nginx/1.0.4
< Date: Wed, 21 Sep 2011 12:06:19 GMT
< Content-Type: application/octet-stream
< Content-Length: 4
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
* Closing connection #0
DONEdrsm at t400:~$
drsm at t400:~$ tail -n2 /usr/local/nginx/logs/access.log
127.0.0.1 - - [21/Sep/2011:16:06:19 +0400] "POST /dummy HTTP/1.1" 200 4 
"-" "curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o 
zlib/1.2.3.4 libidn/1.18"
127.0.0.1 - - [21/Sep/2011:16:06:19 +0400] "OMG" 400 0 "-" "-"
drsm at t400:~$ tail -n1 /usr/local/nginx/logs/error.log
2011/09/21 16:06:19 [info] 1196#0: *19 client closed prematurely 
connection while reading client pipelined request line, client: 
127.0.0.1, server: localhost, request: "OMG"
drsm at t400:~$


> Maxim Dounin
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
Artem

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4438 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20110921/2eccc8c6/attachment.bin>


Подробная информация о списке рассылки nginx-ru