首页 \ 问答 \ get的cURL大小限制(cURL size limit of get)

get的cURL大小限制(cURL size limit of get)

我想知道是否有任何方法通过cURL获取特定数量的数据?

选项1:
curl_setopt ($curl_handle, CURLOPT_HTTPHEADER, array("Range: bytes=0-1000")); 但它不受所有服务器支持

选项2:
无法限制PHP的cURL函数的下载大小,但是这个函数给了我错误Failed writing body (0 != 11350)和阅读,我发现很多人都说它是一个错误。

所以,在上面的write_function我尝试curl_close($handle)而不是returning 0但是这会引发一个错误Attempt to close cURL handle from a callback

现在我能想到的唯一方法是解析标头的内容长度, but this will eventually result in 2 requests ?? 首先使用CURLOPT_NOBODY获取标题,然后获取完整内容?


I want to know if there is any way to get only a particular amount of data through cURL?

Option 1:
curl_setopt ($curl_handle, CURLOPT_HTTPHEADER, array("Range: bytes=0-1000")); but Its not supported by all servers

Option 2:
Having trouble limiting download size of PHP's cURL function but this function is giving me error Failed writing body (0 != 11350) and reading for which I found that many say its a bug.

So following the above write_function I tried to curl_close($handle) instead of returning 0 but this throws an error Attempt to close cURL handle from a callback

Now the only way I can think of is parsing headers for content length but this will eventually result in 2 requests ?? first getting headers with CURLOPT_NOBODY then getting full content?


原文:https://stackoverflow.com/questions/5464914
更新时间:2023-07-15 11:07

最满意答案

从Qt Designer为顶级窗口小部件创建子类。 使用这种方法,Qt Designer中的所有子窗口小部件都将成为子类的属性:

import sys
from PySide import QtCore, QtGui
from ui.mainwindow import Ui_MainWindow

class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.start_button.clicked.connect(self.start_button_clicked)

    def start_button_clicked(self):
        print "started"

if __name__ == '__main__':

    app = QtGui.QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

Create a subclass for the top-level widget from Qt Designer. Using this approach, all of child widgets from Qt Designer will become attributes of the subclass:

import sys
from PySide import QtCore, QtGui
from ui.mainwindow import Ui_MainWindow

class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.start_button.clicked.connect(self.start_button_clicked)

    def start_button_clicked(self):
        print "started"

if __name__ == '__main__':

    app = QtGui.QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

相关问答

更多
  • 我认为我的问题与我连接信号和插槽的风格有关。 我找到了这篇精彩的文章 ,引导您了解新风格。 我在MyLineEdit的构造函数之前创建了一些变量。 然后我在tab_event函数中使用了这些变量。 然后我用新的连接语法将信号连接到插槽。 这是带注释的更新代码: from PySide import QtCore, QtGui from shiboken import wrapInstance import maya.OpenMayaUI as mui def maya_main_window(): ...
  • 你要求的信号是colorSelected ,这是在按OK按钮后发出的 class Widget(QWidget): def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.color_chooser = QColorDialog() self.color_chooser.colorSelected.connect(self.color_pick) ...
  • 插槽是功能。 插槽和函数之间的唯一区别在于,使用slot关键字,Qt元对象编译器(MOC)将获取该函数的函数指针并将其用于其自身目的(如响应信号)。 您可以通过抓取某个函数的指针完全重现这种过程,并在布尔值为true时调用它。 希望有所帮助。 PS:我的背景和技能与C ++有关,但你应该明白我的观点;) Slots are functions. The only difference between slots and functions is that with the slot keyword, the ...
  • 您的示例有点破碎,因为您忘记设置布局的父级,并且还将滑块小部件保存为稍后要访问的成员属性...但是要回答您的问题,它就像指向您的连接一样简单对你自己的功能: class MyMainWindow(QWidget): def __init__(self): QWidget.__init__(self, None) vbox = QVBoxLayout(self) self.sone = QSlider(Qt.Horizontal) s ...
  • 从Qt Designer为顶级窗口小部件创建子类。 使用这种方法,Qt Designer中的所有子窗口小部件都将成为子类的属性: import sys from PySide import QtCore, QtGui from ui.mainwindow import Ui_MainWindow class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self): super(MainWindow, self ...
  • 对,是。 新的语法更清晰,为什么不呢? 请注意,当您尝试按名称连接插槽时,必须显式调用connectSlotsByName,因为没有预处理器在执行之前运行并将它们连接起来。 PS:除此之外,信号/插槽连接的C ++语法只是丑陋的,旧的PyQt语法没有任何原因非常相似,所以我很高兴在PyQt中看到这种变化。 PS2:最近有关于此的问题,请查看。 Yes, that is. New syntax is more clear, so why not? Note, that when you trying to c ...
  • 如果没有完整的示例,很难确切地看到您的实现有什么问题。 如果对象超出范围(如果未在堆上初始化),则有时信号或插槽将失败。 另一种可能失败的方法是你的QApplication没有到达exec()调用。 我没有尝试在信号和插槽调用中使用const,我之前没有在任何例子中看到它,因此可能导致问题; 但它似乎在下面的例子中工作正常。 带有QTextEdit派生类的工作示例 这是一个简单的例子,我把它放在一起,用按钮和行编辑进行一些基本的记录。 这是标题: #ifndef WIDGET_H #define WIDGE ...
  • 我在其他帖子中找到了答案: StackOverflow:Pyside setText()不更新QLabel 在这种情况下,窗口小部件不会重新绘制,因此需要强制应用程序重新绘制它。 我使用了这段代码(参见PySide Docs:QApplication ): def updateAllWidgets(): for widget in QApplication.allWidgets(): widget.update() 例如,定时器可以调用此函数: timer = QtCore.QTi ...
  • 它们不是副本 。 如果检查它们的类型,您将看到class属性是PySide.QtCore.Signal ,实例属性是PySide.QtCore.SignalInstance 。 print "type(obj1.sig): {}".format(type(obj1.sig)) print "type(obj2.sig): {}".format(type(obj2.sig)) print "type(Klass.sig): {}".format(type(Klass.sig)) # type(obj1.si ...
  • 在c ++代码中连接信号和插槽并在QtCreator“信号和插槽编辑器”窗口中设置它们之间的区别是什么? 没有。 使用编辑器时,它会将数据写入.ui文件,然后使用uic预处理器创建C ++代码。 还有一个“信号和插槽编辑器”小部件和“动作编辑器”小部件,以便我可以添加和编辑。 但什么时候应该使用它? 或者我可以忽略它? 请告诉我,遵循的最佳规则是什么。 没有“遵循规则”,这是个人品味。 我个人认为Designer是一个使用的钝器,所以除了对话之外,我很少使用它; 而其他人则发现它很有帮助,尽可能多地使用它。 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。