本文介绍了网址中的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

声称网址可以包含空格:



这是真的吗?网址如何包含未编码的空格?



我的印象是使用空格作为分隔符,格式为 {方法} {space} {path} {space} {协议}

  GET /index.html http / 1.1 

因此,URL如何包含空格?如果可以的话,用 + 替换空格的做法来自哪里?

解决方案

网址不得包含文字空间。必须使用或使用网址安全字符(例如对于空格使用 + 而不是%20



%20 不是空格(显然),但代表空格。


w3fools claims that URLs can contain spaces: http://w3fools.com/#html_urlencode

Is this true? How can a URL contain an un-encoded space?

I'm under the impression the request line of an HTTP Request uses a space as a delimiter, being formatted as {the method}{space}{the path}{space}{the protocol}:

GET /index.html http/1.1

Therefore how can a URL contain a space? If it can, where did the practice of replacing spaces with + come from?

解决方案

A URL must not contain a literal space. It must either be encoded using the percent-encoding or a different encoding that uses URL-safe characters (like application/x-www-form-urlencoded that uses + instead of %20 for spaces).

But whether the statement is right or wrong depends on the interpretation: Syntactically, a URI must not contain a literal space and it must be encoded; semantically, a %20 is not a space (obviously) but it represents a space.

这篇关于网址中的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:09