首页 \ 问答 \ Jsoup,HTTPClient,HttpURLConnection。(Jsoup, HTTPClient, HttpURLConnection. How to get a response html, if the server always returns a 413 error code)

Jsoup,HTTPClient,HttpURLConnection。(Jsoup, HTTPClient, HttpURLConnection. How to get a response html, if the server always returns a 413 error code)

当向http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=[request string]服务器发送GET请求时,始终响应413错误。 在浏览器中,此请求显示带有javascript重定向的html页面。 但是在Jsoup中获取此URL时抛出异常。 我认为这是为了防止自动登录。我想得到响应的html宽度Jsoup。

try{
Response response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET).execute();
}
catch (HttpStatusException e) {
//? What i must write here to get response
}

在C#/。Net HttpWebRequest Exception对象中包含Response,我可以从中提取html数据。 如何在java / android中做到这一点?

对不起我的英语不好。


When sending a GET request to http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=[request string] server always response 413 error. In browser this request show html page with javascript redirect. But in Jsoup when get this URL throwed exception. I think this is to prevent automated login.I want to get responsed html width Jsoup.

try{
Response response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET).execute();
}
catch (HttpStatusException e) {
//? What i must write here to get response
}

In C#/.Net HttpWebRequest Exception object contain Response and I can extract html data from it. How to do it in java / android?

Sorry for my English.


原文:https://stackoverflow.com/questions/19958836
更新时间:2022-06-06 13:06

最满意答案

就可访问的API而言,听起来你已经找到了相关的点点滴滴。 如果您还没有,请阅读此stackoverflow项目

使用Choreographer和外推,您可以猜测下一次显示刷新的时间。 在Android 5.0+设备上使用eglPresentationTimeANDROID() ,您可以在需要将特定帧发送到显示器时告诉SurfaceFlinger。 假设SurfaceFlinger正确考虑了所有延迟(例如“智能”面板添加的额外帧),那么应该可以获得可靠的时序。

(请记住,时间基于显示器锁定下一帧的时间,而不是下一帧在显示器上完全可见时...时间延迟取决于面板。)

Grafika的 “预定交换”活动使用此功能,但听起来你已经熟悉了。

当它进行交换时,显示器发出信号的唯一方法是从前一帧中dup() display dup() display-retire fence fd,然后等待它。 SurfaceFlinger中的一些代码执行此操作,特别是DispSync监视退役围栏以查看软件“VSYNC”是否正在漂移。 没有用于围栏的公共API,并且用户空间响应时间肯定可能超过1毫秒......它通常比预先做好反应更好。 您对非root用户非自定义设备的要求会导致此问题。

如果您大多看到正确的行为,但偶尔会看到错过,您最好的选择是使用systrace来追踪原因。


As far as accessible APIs go, it sounds like you've found the relevant bits and pieces. If you haven't yet, please read through this stackoverflow item.

Using Choreographer and extrapolation, you can guess at when the next display refresh will occur. Using eglPresentationTimeANDROID() on an Android 5.0+ device, you can tell SurfaceFlinger when you want a particular frame to be sent to the display. Assuming SurfaceFlinger is properly accounting for all latency (such as additional frames added by "smart" panels), that should get you reliable timing.

(Bear in mind that the timing is based on when the display latches the next frame, not when the next frame is fully visible on the display... the latency there will depend on the panel.)

Grafika's "scheduled swap" Activity uses this feature, but it sounds like you're already familiar.

The only way to get signaled by the display when it does the swap would be to dup() the display-retire fence fd from the previous frame, and wait on it. Some of the code in SurfaceFlinger does this, notably DispSync watches the retire fences to see if the software "VSYNC" is drifting. There is no public API for fences, and the user-space response time could certainly be more than 1ms anyway... it usually works out better to schedule ahead than it does to react. Your requirement for non-rooted non-custom devices makes this problematic.

If you're mostly seeing correct behavior, but occasionally seeing a miss, your best bet is to use systrace to track down the cause.

相关问答

更多
  • 你必须管理相同的计数。 做这个: int touchCount = 0; ImageView img = (ImageView) findViewById(R.id.image); img.setOnClickListener(new OnClickListener() { public void onClick(View v) { touchCount = touchCount + 1; if (touchCount == 3){ to ...
  • 您应该将变换应用于父视图(您的UIWindow)。 旋转可以使用CGAffineTransformMakeRotation() 。 实际上允许设备方向可以引起旋转,但可能会更好。 在应用程序设置设置,该应用程序支持自动旋转,然后在UIViewController返回ü -(BOOL)shouldAutorotateToInterfaceOrientation旋转传入时UIInterfaceOrientationPortraitUpsideDown You should apply a transform t ...
  • 重新启动活动后,将布尔值设置为true 。 重启完成后将其设置为false 。 仅当startActivity为false时才调用startActivity 。 声明一个字段: private boolean mRestarted = false; 在restartActivity : void restartActivity() { if(!mRestarted} { Intent intent = getIntent(); finish(); st ...
  • 我认为此链接对您有所帮助。 尝试一下,我相信它会清除你的怀疑:))) I think this link will be helpful to you. Try it and I'm sure it will clear out your doubts :)))
  • 就可访问的API而言,听起来你已经找到了相关的点点滴滴。 如果您还没有,请阅读此stackoverflow项目 。 使用Choreographer和外推,您可以猜测下一次显示刷新的时间。 在Android 5.0+设备上使用eglPresentationTimeANDROID() ,您可以在需要将特定帧发送到显示器时告诉SurfaceFlinger。 假设SurfaceFlinger正确考虑了所有延迟(例如“智能”面板添加的额外帧),那么应该可以获得可靠的时序。 (请记住,时间基于显示器锁定下一帧的时间,而 ...
  • 所以我添加了一个Hack来使这个工作在Tab4上。 在应用旋转功能结束时,我添加了以下代码。 // hack for the Tab 4 new CountDownTimer(mFlipAnimationTime * 2, 33) { @Override public void onTick(long millisUntilFinished) { mFlipView.refreshDrawableState(); ...
  • 在AndroidManifest.xml文件的元素中设置android:screenOrientation="landscape" 。 Set android:screenOrientation="landscape" in the element of your AndroidManifest.xml file.
  • 微调器的默认背景是9-patch drawable ,因此它可以相应缩放。 如果要反转箭头,则必须复制绘图并手动反转。 在这里,我采用了Lollipop 1上发现的旋转器的背景并垂直翻转: 您可以复制该文件并将其作为9补丁(即扩展名为.9.png (不仅仅是.png ))保存到drawable-xxxhdpi文件夹中。 1 [android-sdk] /platforms/android-22/data/res/drawable-xxxhdpi/spinner_mtrl_am_alpha.9.png 从Ma ...
  • 你可以通过编程来完成。 这里是Xamarin的C#。 目前无法测试Java,但它会非常相似。 ImageView block = FindViewById(Resource.Id.imgBlock); ObjectAnimator blockSpin = ObjectAnimator.OfFloat(block, "rotationX", 0, 360); imageCard.PivotX = 0.5f; //so it spins on center float scale = m ...
  • 我创建了一个包含一系列有用小部件的Android库 - 它叫做UsefulViews 。 其中一个小部件是FlippableView 。 您可以查看Javadoc以了解它是如何工作的。 I've made an Android library that contains a collection of useful widgets - it's called UsefulViews. One of these widgets is the FlippableView. You can have a look ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)