Welcome! Log In Create A New Profile

Advanced

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

Artem S. Povaluhin
September 21, 2011 08:10AM
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@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@t400:~$
drsm@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@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@t400:~$


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

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Attachments:
open | download - smime.p7s (4.3 KB)
Subject Author Posted

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

JohnBat26 September 21, 2011 05:20AM

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

Михаил Монашёв September 21, 2011 06:56AM

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

Maxim Dounin September 21, 2011 07:14AM

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

Maxim Dounin September 21, 2011 07:14AM

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

Artem S. Povaluhin September 21, 2011 08:10AM

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

Maxim Dounin September 21, 2011 08:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 98
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready