skalkanci
skalkanci

Reputation: 61

How to handle (REAL) blank space in Apache?

I know there are many questions like that in stackoverflow. But it is actually different :)

My problem is that Apache (2.4.6) just cannot handle white spaces in a url for instance aspecially used by cURL. Well consider I have a URL like following:

http://10.0.0.1:1234/Some Service/Root?func=getMessage

IF I browse this URL in any popular browser, they change the white space (' ') to %20. And in that way Apache can handle the request (or wget also does so).

However, when I use cURL, it does not change to %20 and in that case Apache return Error 400. I think the reason is, in the end of the GET Url, there is a white space and then specifies the used HTTP protocol comes. such as: GET Some Service/Root?func=getMessage HTTP1.1

The problem is I cannot touch or perform any update on cURL site. For example, I cannot perform a sed operation before cURL request. So consider like cURL site is like a blackbox. I have no control on that site. Therefore, I really have to solve this problem only in Apache. Unfortunately, It is the only option for me.

RewriteRules that I found work with if URL contains %20 instead of real white space (' '). For example \s only for if I write down %20 in the curl request. For example: curl -v "http://10.0.0.1:1234/Some%20Service/Root?func=getMessage"

But if I use like: curl -v "http://10.0.0.1:1234/Some Service/Root?func=getMessage" then it gets Erro 400 because of the space.

For example following solution for %20 exists if there is one space or more then one:

#executes repeatedly as long as there are more than 1 spaces in URI

RewriteRule "^(\S*)\s+(\S* .*)$" $1+$2 [N,NE]

#executes when there is exactly 1 space in URI

RewriteRule "^(\S*)\s(\S*)$" /$1+$2 [L,R=302,NE]

So my link may not as simple as following: http://10.0.0.1:1234/Some Service/Root?func=getMessage

Probably it may include one space :) but there will be more than one parameters like http://10.0.0.1:1234/Some Service/Root?func=doSomething&id=123&pid=123&message=blabla&name=john&surname=doe

But in any case, ofcourse, I need also prevent possible problems if there is more then one blank.

Thanks in advance

Upvotes: 0

Views: 1286

Answers (1)

skalkanci
skalkanci

Reputation: 61

It seems that Nginx can handle blanks or white spaces. Nginx does not give 400.

Upvotes: 1

Related Questions