网址中的空格? [英] Spaces in URLs?

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

问题描述

w3fools 声称网址可以包含空格: http://w3fools.com/#html_urlencode



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



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

  GET /index.html http / 1.1 

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

解决方案

网址不得包含文字空间。必须使用百分比编码或使用<的其他编码进行编码a href =https://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940>网址安全字符(例如 application / x-www-form-urlencoded 对于空格使用 + 而不是%20



<但是,语句是对还是错取决于解释:从语法上讲,URI不能包含文字空间,必须对其进行编码;在语义上,%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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆