uri

URL to URI encoding changes a “%3D” to “%253D”

浪子不回头ぞ 提交于 2020-01-10 18:17:15
问题 I'm having trouble encoding a URL to a URI: mUrl = "A string url that needs to be encoded for use in a new HttpGet()"; URL url = new URL(mUrl); URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), null); This does not do what I expect for the following URL: Passing in the String: http://m.bloomingdales.com/img?url=http%3A%2F%2Fimages.bloomingdales.com%2Fis%2Fimage%2FBLM%2Fproducts%2F3%2Foptimized%2F1140443_fpx.tif%3Fwid%3D52%26qlt%3D90%2C0%26layer%3Dcomp

Nginx Rewrite相关功能

和自甴很熟 提交于 2020-01-10 18:03:09
Nginx服务器利⽤ngx_http_rewrite_module 模块解析和处理rewrite请求,此功能依靠 PCRE(perl compatible regularexpression),因此编译之前要安装PCRE库,rewrite是nginx服务器的重要功能之⼀,⽤于实现URL的重写,URL的重写是⾮常有⽤的功能,⽐如它可以在我们改变⽹站结构之后,不需要客⼾端修改原来的书签,也⽆需其他⽹站修改我们的链接,就可以设置为访问,另外还可以在⼀定程度上提⾼⽹站的安全性。 1 ngx_http_rewrite_module模块指令 官方文档:https://nginx.org/en/docs/http/ngx_http_rewrite_module.html 1.1 if指令 # ⽤于条件匹配判断,并根据条件判断结果选择不同的Nginx配置,可以配置在server或location块中进⾏配置,Nginx的if语法仅能使⽤if做单次判断,不⽀持使⽤if else或者if elif这样的多重判断,⽤法如下: if (条件匹配) { action } # 使⽤正则表达式对变量进⾏匹配,匹配成功时if指令认为条件为true,否则认为false,变量与表达式之间使⽤以下符号链接: = #⽐较变量和字符串是否相等,相等时if指令认为该条件为true,反之为false。 != #

从相册获取图片并转换为文件数组并上传

天大地大妈咪最大 提交于 2020-01-10 14:30:23
程序从一个dialog开始: private void show() { final Dialog dialog = new Dialog(this, R.style.ActionSheetDialogStyle); View inflate = LayoutInflater.from(this).inflate(R.layout.dialog_item, null); //相册 Button bt_camera = inflate.findViewById(R.id.bt_camera); //取消 Button bt_cancel = inflate.findViewById(R.id.bt_cancel); dialog.setContentView(inflate); Window dialogWindow = dialog.getWindow(); dialogWindow.setGravity(Gravity.BOTTOM); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); lp.y = 20; dialogWindow.setAttributes(lp); //取消按钮 bt_cancel.setOnClickListener(new View.OnClickListener() {

Android生成二维码--拍照或从相册选取图片

旧街凉风 提交于 2020-01-09 20:33:38
拍照或从相册选择图片是我们日常开发中经常使用到的,可以说是必须掌握的东西。上一篇我介绍了如何生成自定义二维码《 Android生成自定义二维码 》,其中logo和代替黑色色块的图片都是写死的,所以现在我们就来实现拍照或者从相册选取图片这个功能。 先看效果图: 拍照 1.启动相机程序 拍照可以直接启动系统的相机程序,代码如下 Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, TAKE_PHOTO); 这里我们利用一个隐式Intent来启动相机程序,其中action类型:android.media.action.IMAGE_CAPTURE 表示启动相机应用并请求一张图片。创建了Intent对象,还需指定图片的保存路径,调用Intent的putExtra()方法并传入保存路径即可,最后调用startActivityForResult启动活动,重写onActivityResult()方法就能得到返回值。 2.指定保存路径 上面的intent中指定了保存路径,也就是代码中的imageUri。首先需要创建一个File对象用来存放图片

SpringCloud OAuth2实现单点登录以及OAuth2源码原理解析

落花浮王杯 提交于 2020-01-08 14:44:34
SpringCloud OAuth2实现单点登录以及OAuth2源码原理解析 意识流丶 关注 42019.05.22 14:39:50字数 2,594阅读 9,647 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一。SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。 Spring Security OAuth 是建立在 Spring Security 的基础之上 OAuth2.0 协议实现的一个类库 Spring Security OAuth2 为 Spring Cloud 搭建认证授权服务(能够更好的集成到 Spring Cloud 体系中) 单点登录主要包括 服务端:一个第三方授权中心服务(Server),用于完成用户登录,认证和权限处理 客户端:当用户访问客户端应用的安全页面时,会重定向到授权中心进行身份验证,认证完成后方可访问客户端应用的服务,且多个客户端应用只需要登录一次即可 相关版本: SpringBoot:2.1.5.RELEASE SpringCloud :Greenwich.SR1 认证中心Server 1.引入OAuth2依赖和web依赖(不加启动时会报无法访问javax.servlet.Filter) OAuth2中包含spring-cloud-starter

URI starting with two slashes … how do they behave?

孤人 提交于 2020-01-08 09:38:11
问题 Lately I saw working code-blocks like this: <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> And according to RFC 2396 (URI Syntax) and RFC 2616 (HTTP 1.1) these URI starting with two slashes are valid, but unfortunately the RFCs don't really explain them. Can anyone point me to a resource which explains how browsers will/should/do process these URIs? 回答1: The resource you're looking for is the RFC 3986. See Section 4.2 and Section 5.4.

URI Formats not Supported: while downloading remote file from Web client in c#

拈花ヽ惹草 提交于 2020-01-07 03:22:11
问题 I'm trying to download a file from the server . While passing a link to the download File , it is throwing an error **URI Formats are not supported ** and pointing at "link "- string contains server file address string link = http:\\www.nse-india.com\DERIVATIVES\2012\AUG\fo22AUG2012bhav.csv.zip WebClient wc = new WebClient(); var ua = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"; wc.Headers.Add(HttpRequestHeader.UserAgent, ua); wc.Headers["Accept"] = "/"; and

Why Uri.parse() does not return valid image uri of an image in the drawable folder?

爱⌒轻易说出口 提交于 2020-01-07 02:56:09
问题 intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpg"); //intent.setType("image/*"); Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/"+R.drawable.test_image); //Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/drawable/test_image"); intent.putExtra(Intent.EXTRA_STREAM, imageUri); intent.putExtra(Intent.EXTRA_TEXT, "Sent from my app"); chooser = Intent.createChooser(intent, "Send Image"); startActivity(chooser); When I

Java's URL/URI doesn't resolve correctly links starting with ? (interrogation point)

妖精的绣舞 提交于 2020-01-06 23:42:17
问题 I'm trying to resolve a relative link that starts with a question mark ? using Java's URL or URI classes. HTML example: <a href="?test=xyz">Test XYZ</a> Code examples (from Scala REPL): import java.net._ scala> new URL(new URL("http://abc.com.br/index.php?hello=world"), "?test=xyz").toExternalForm() res30: String = http://abc.com.br/?test=xyz scala> (new URI("http://abc.com.br/index.php?hello=world")).resolve("?test=xyz").toString res31: java.net.URI = http://abc.com.br/?test=xyz The problem

如何保存HTTPrequestbase和CloseableHttpResponse

自闭症网瘾萝莉.ら 提交于 2020-01-06 21:57:12
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在测试过程中,有一个重要的工作就是保存记录“现场”,以方便开发人员更快发现BUG解决问题。在接口测试中更是如此,如果开发人员能够根据BUG的信息直接复现请求,是一件很方便的事情。为此我想了一个再框架中增加保存HTTPrequestbase和CloseableHttpResponse两个对象的功能,其中主要是HTTPrequestbase的信息,CloseableHttpResponse以响应内容为主,因为每次请求我都会把必要信息(host,API,HTTP code,响应code,响应时间等等记录)。 下面是更新过的 funrequest 类的代码,更新内容时后面几个静态方法: package com.fun.frame.httpclient import com.fun.base.bean.RequestInfo import com.fun.base.exception.RequestException import com.fun.config.HttpClientConstant import com.fun.config.RequestType import com.fun.frame.Save import com.fun.utils.Time import net.sf.json