Skip to content

NEST Refresh() method fails if using IIS proxy #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maximpashuk opened this issue Apr 4, 2014 · 2 comments
Closed

NEST Refresh() method fails if using IIS proxy #562

maximpashuk opened this issue Apr 4, 2014 · 2 comments

Comments

@maximpashuk
Copy link

NEST do a POST request for Refresh method and does not set Content-Length header.

In common case NEST should set it, because POST request implies that you have message body, so you always should set Content-Length for POST requests (if no body provided then you should set zero)

http://www.w3.org/Protocols/rfc2616/rfc2616.txt

Elasticsearch is using Netty web server, that is tolerant and allows POST requests without Content-Length provided.

BUT if I use IIS reverse proxy behind of elasticsearch, then IIS not allowing such requests

1

If I use elasticsearch-head, then all is OK, elasticsearch-head is setting Content-Length:0 for Refresh method

2

I am not familiar with code, but I think changes required in file HttpConnection.cs

https://github.com/elasticsearch/elasticsearch-net/blob/f85ce38eca2d1ed13f4f5a094c13d9ec1da77b0a/src/Elasticsearch.Net/Connection/HttpConnection.cs

in method CreateWebRequest add something like

if (method == "Post"){
myReq.ContentLength = 0;
}

oк using IRequestConnectionConfiguration interface

@Mpdreamz
Copy link
Member

Mpdreamz commented Apr 4, 2014

Thanks @maximpashuk

The .NET http webrequest object will set Content-Length if its given a body but not won't set it to 0 for POST/PUT/DELETE's without a body.

Nice catch! will update accordingly.

@Mpdreamz
Copy link
Member

Mpdreamz commented Apr 4, 2014

Ty @maximpashuk appreciate the effort you took in reporting this with screenshots by the way really helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants